SQL Loader: Help TRIM and Decode functions please

Hello

I have load data from a flat file, for some columns, I need to use the TRIM and DECODE functions. It's a pipe delimited file.

I get a syntax error (one is lower) same error listed for GARNISH.

SQL * Loader-350: at line xx syntax error.
Expected ', 'or') ', found 'DECODE '.


===========
, FINAL_BILL_DATE CHAR (30) "TRIM(:FINAL_BILL_DATE)".
, BUSINESS_ID 'DECODE(:BUSINESS_ID,'B',1,'C',2,'E',3,'G',4,'O',5,'R',6,'T',7,'U',8,'H',9,-1) '.


Can someone please help.

Thank you
Josiane

Hello josiane.
The error you receive leads me to believe that at some point before the DECODING on the BUSINESS_ID line, probably some line before the FINAL_BILL_DATE line, it is a syntactic error causing the quotes before DECODING actually put an end to some other syntaxes. Without any lines that might actually contribute to this, including details of the header, it's the best I can advise.

Hope this helps,
Luke

Please check the answer as helpful or response, if it is so. If this is not the case, further clarification.
Try to always provide create table and table insert to help members of the forum to help you.

Tags: Database

Similar Questions

  • SQL Loader Help in 10g

    Hello

    Is it possible to abort the sql loader with force when a value is not present? I have data like this file

    1. XXX123 | XXX | 20121121 |
    4. XXX123 | XXX |
    5. XXX123 | XXX | 1.
    5. XXX123 | XXX | 2.
    5. XXX123 | XXX |
    9. XXX123 | XXX |

    Model:
    record type | Batch number. lot desc | date | detail line num | other

    1,4,5,9 are the types of records, if you see this line 5. XXX123 | XXX | 1| .. 1 represents a number of detail line, my requirement is if the number of detail line is null for the record type 5 then I want to abort the sqlloader.

    Is this possible?

    Published by: 940838 on November 21, 2012 23:54

    940838 wrote:
    I think that I am not clear in my requirement...

    The question was how to abort the charger if the number of detail line is not present in the record type 5. It is, however, normal detailing line num is not required for other types of records. points of view.

    Hello

    you were clear, and I did a quick test. Unfortunately you can not do this check in SQL * Loader as the WHEN in the control file clause allows not just GOLD.

    Even if you add this check using a constraint in your table and specify the maximum number of errors to 0, SQL * Loader will load the files until this error.

    Let me show you an example:

    (1) create a table with a constraint that, for record_type detail_line_number 5, may not be null.

    CREATE TABLE test
    (
       record_type    INTEGER
     , batch_number   VARCHAR2 (10)
     , batch_desc     VARCHAR2 (10)
     , batch_date     DATE
     , detail_line_num INTEGER
     , other          VARCHAR2 (10)
    );
    
    ALTER TABLE test
      ADD CONSTRAINT check_rec_5
         CHECK (   record_type = 5 AND detail_line_num IS NOT NULL
                OR record_type != 5) ENABLE;
                
    

    In this table, you will not be able to load lines with a record_type = 5 and NULL detail_line_num as this will be considered an error.

    We will prepare your input file:

    1|XXX123|XXX|20121121||
    4|XXX123|XXX|||
    5|XXX123|XXX||1|
    5|XXX123|XXX|||
    5|XXX123|XXX|||
    9|XXX123|XXX|||
    1|XXX123|XXX|20121121||
    4|XXX123|XXX|||
    5|XXX123|XXX||1|
    5|XXX123|XXX||2|
    5|XXX123|XXX|||
    9|XXX123|XXX|||1|XXX123|XXX|20121121||
    4|XXX123|XXX|||
    5|XXX123|XXX||1|
    5|XXX123|XXX||2|
    5|XXX123|XXX|||
    9|XXX123|XXX|||1|XXX123|XXX|20121121||
    4|XXX123|XXX|||
    5|XXX123|XXX||1|
    5|XXX123|XXX||2|
    

    As you can see that the input file has the fourth line with record_type = 5 and detail_line_num NULL. It is a mistake of the constraint.

    Here I used the control file:

    --test.ctl
    load data
    INFILE 'test.dat'
    APPEND
    INTO TABLE test
    FIELDS TERMINATED BY '|'
    TRAILING NULLCOLS
    (
     record_type     ,
     batch_number    ,
     batch_desc      ,
     batch_date      Date 'YYYYMMDD',
     detail_line_num ,
     other
    )
    

    If I try to run the SQL * Loader and ask to stop at the first error in this way:

    sqlldr userid=yourname/yourpass@yourdb control=test.ctl errors=0 rows=100
    

    SQL * Loader performs only 3 folders because it encounters an error in line 4 and having specified errors = 0 will not continue to load. In fact, the process will continue until she reached the point of validation (in this case 100 lines), but it is not loading any record after the error, or continue to read the file.

    So, if I check the table

    SELECT * FROM test;
    
    RECORD_TYPE BATCH_NUMBER BATCH_DESC BATCH_DATE            DETAIL_LINE_NUM OTHER
    ----------- ------------ ---------- --------------------- --------------- ----------
              1 XXX123       XXX        21-11-2012 00:00:00
              4 XXX123       XXX
              5 XXX123       XXX                                            1           
    

    You will only see the records until you have reached the error.

    This can be avoided, as documented in SQL * Loader manual reference:

    Load interrupted because they exceeded the maximum number of errors


    If the maximum number of errors is exceeded, SQL * Loader stops loading documents in any table and the work accomplished so far is committed.

    As you can see SQL * Loader to interrupt the treatment, but it engage in any case files until this error.

    Another solution is to create an external table in Oracle and do all the checks you want before you copy your table in a database table, as suggested BluShadow.

    Kind regards.
    Al

  • Please help fix the Decode function

    DECODE (p_resp_key,'|) "' AP" ' |', LINT_LOGI_STG_ITEM_DETAILS_PKG. Description of the AS GET_AP_ITEM_CATEGORY_DTL (ol.inventory_item_id), ldmf_istore_order_pkg.get_wwdb_prod_description (ol.inventory_item_id))

    I'm getting errors during execution analysis. I believe that something is incorrect in Decode statement. I call this statement of Decopde in the package. Help, please.

    Concerning
    M

    I think I've found the error:

    p_resp_key is a parameter to your home...

    If it could work.

     := 'select ... DECODE('''||p_resp_key||''',''AP'',LINT_LOGI_STG_ITEM_DETAILS_PKG.GET_AP_ITEM_CATEGORY_DTL(ol.inventory_item_id),ldmf_istore_order_pkg.get_wwdb_prod_description(ol.inventory_item_id)) AS description ...'
    

    I still very strongly suggest to do not to use the dynamic version of this code. You have a couple of potential Sql Injection issues in there and it will be better if its not done dynamically.

    Published by: W. Sven on September 11, 2009 14:15

    Published by: W. Sven on September 11, 2009 14:17

  • SQL Loader help required

    HI team,

    I need to load data in to table using sqlloader, as I'm going to level three (header, detail, end "")
    the first two positions of the data file representing the level as
    00-header
    01 to 98 - retail
    99 - trailer
    each level has different data structure and we need to insert in the same table
    I created the table as

    CREATE TABLE APPLICATIONS. XXD_TEST1
    (
    THE AA NUMBER,
    TEST12 VARCHAR2 (10 BYTE),
    testdt VARCHAR2 (10 BYTE),
    testtr VARCHAR2 (10 BYTE),
    NUMBER OF RECORD_ID
    )

    and a sequence created to record_id column
    -CREATE SEQUENCE APPLICATIONS. XXD_TEST1_S

    I have data in the data file as below, I want to load the data in the same order
    -------------------------------------
    000012
    010012
    010012
    020012
    030012
    990012
    000013
    010013
    020013
    030013
    990013

    I was using the folowwing control file
    -----------------------------------
    DOWNLOAD THE DATA
    Test INFILE
    ADD
    IN THE TABLE xxd_test1
    WHEN (1:2) = '00'
    TRAILING NULLCOLS
    (
    Test12 POSITION(3:6) CHAR,
    AA POSITION(1:2) INTEGER EXTERNAL "lpad(:aa,2,'0')."
    record_id 'xxd_test1_s.nextval '.
    )
    IN THE TABLE xxd_test1
    WHEN (1:2)! = '99' and (1:2)! = '00'
    TRAILING NULLCOLS
    (
    testdt POSITION(3:6) CHAR,
    AA POSITION(1:2) INTEGER EXTERNAL "lpad(:aa,2,'0')."
    record_id 'xxd_test1_s.nextval '.
    )
    IN THE TABLE xxd_test1
    WHEN (1:2) = '99'
    TRAILING NULLCOLS
    (
    testtr POSITION(3:6) CHAR,
    AA POSITION (1:2) INTEGER EXTERNAL,
    record_id 'xxd_test1_s.nextval '.
    )

    But it was inserted in the following order

    -----------------------------------------
    000012
    000013
    010012
    010012
    020012
    020013
    030012
    030013
    990012
    990013

    Please help me with the solution.

    Thank you
    Sriram.

    [Double wire | http://forums.oracle.com/forums/thread.jspa?threadID=979069&tstart=0]

  • Need help with the DECODE function

    Hello

    I try to use by default within the decode service and whenever I get a missing expression. I searched everywhere and can not know what I am doing wrong. Thank you

    Select decode (request_id, 0, "no file found", by DEFAULT)
    select decode (request_id,0,'No files found', request_id)...
    
  • SQL LOADER HELP

    I need to write the file to control for the following requirement.

    I have data like this

    1. ABC | XYZ | 123
    2. ABC1. XYZ1


    I have two tables (tb1_col1, tb1_col2, tb1_col3) tb1 and tb2 (tb2_col1, tb2_col2)

    I need to insert the data into two different tables according to the condition:

    If the first new line char is 2 then insert into tb2 table with values xyz1 and abc1 in the columns tb2_col1, tb2_col2
    Otherwise, if it's 1 insert then abc, xyz, 123 in tb1 with the values in the columns tb1_col1, tb1_col2, tb1_col3

    I got reallyl grateful if someone can help out me. Thanks in advance

    With the help of 'external tables' in this scenario would be really useful in this scenario, if you ask me.

    What is the version of database?

    Select * from version of v$.

    As you do using the external table is:

    You can define an external table on the file, then

    Insert into table1
    Select * from your_external_table_name
    where first_column = 1;

    Insert into table2
    Select some_columns from your_external_table_name
    where first_column = 2;

  • SQL loader by using functions and position

    Hi all, I need help, loading data in my table using sql loader. study the following
    CREATE TABLE er
    (                     
    a1 NUMBER,
    a2 number,
    a3 VARCHAR2(100),
    a4 VARCHAR2(100),
    a5 VARCHAR2(100),
    a6  VARCHAR2(100),
    a7  VARCHAR2(100),
    a8  VARCHAR2(100)
    );
    
    OPTIONS (BINDSIZE=20548000, READSIZE=20548000, STREAMSIZE=20548000, DATE_CACHE=25000,  SKIP=0)
    LOAD DATA
    INTO TABLE er
    APPEND     
    TRAILING NULLCOLS
    (
      a1            POSITION(0001:0021)               ,
      a2            POSITION(0022:0042)       "DECODE(SUBSTR(:a2,1,3),'***',NULL,:a2)"      ,
      a3            POSITION(0043:0053)       ,
      a4            POSITION(0054:0064)          ,
      a5            POSITION(0065:0075)           ,
      a6            POSITION(0076:0086)       ,
      a7            POSITION(0087:0093)      "DECODE(SUBSTR(:a7,1,3),'***',NULL,:a7)"   
    )
    BEGIN
                     0.00 ******************** X          X          X          *X          ****
    END;
    If you look at the data, some fields have a lot of * and some af a bit such as *. I want to load data into a table, and when a field contains all * as the value, I want to set to null. If a field contains a * and alphanumeric, so this value should be as it is.

    in the above example, * must be set to null and * should also be defined with a null value. Note that there is a field with x as this area contain alpha numeric, it must be loaded into the table, as is.  the only time in field must be set to null, it's when the value contains all .

    someone in this forum suggest using to decode, but looks like it doesn't work and I get error when it reads the second field and try to insert into the column number a2.

    is it possible to use regular expressions to find out if a field contains all *. I also want to cut each field as they may contain spaces.
    can be a help for this, use the ctl sqlloader and above?

    You can include regular expressions in you SQL * file the charger control.

    An example can be found here:
    http://www.morganslibrary.org/reference/sqlloader.html
    Demos of 7 and 8 by using the UPPER and DECODE functions to illustrate how do.

  • SQL Loader and Oracle 11g

    Hello

    IM receiving a sqlldr: not found error. IM is going to discuss with our system of administration of the situation. Before I wanted to make sure that SQL Loader (sqlldr) is an add-on available for customer Oracle 11. A colleague mentioned SQLLDR maybe isn't available as an add-on in the Oracle 11 client and that we should rather use IMPORT/EXPORT. Is that a true statement?

    Can someone please clarify these questions for me?

    Thanks a bunch!

    SQL * Loader is certainly available in 11.1 or 11.2 full client install. It may or may not be a component that is installed by default according to the type of installation you choose during installation. But you can always go back and install this component.

    If you mean the instant customer, I'm not sure that SQL * Loader or import and export work with the Instant Client.

    And just to the point, if you are using 11g, you usually would using external tables rather than SQL * Loader.

    Justin

  • SQL Loader - does not

    I have Oracle 11 g R2 running on Windows Server 2008 R2

    When trying to load the data (csv file) with SQL Loader in Enterprise Manager, he told me the work successfully completed, but there is no data in the table. The bat is created as the ctl and sh file. I checked that sqldr is in my directory \bin to $ORACLE_HOME$ and I checked that this 'path' is also in my path environment variable. When I try to run it from the command line that I don't get recognized as builtin or external, an executable program or batch file. I try to run it in SQL Developer, and after his execution, it is said canceled task. Can help you. I expect a record 70 million next week and I want to use SQL Loader.

    Message from Enterprise Manager
    State managed
    Exit code 0
    31327 step ID
    Target leads.global
    Started may 10, 2013 15:55:14 (UTC-07:00)
    Ended May 10, 2013 15:55:22 (UTC-07:00)
    Step 8 seconds
    WIN Service Management - D1CINRVM11K:1158_Management_Service
    Including the job step ADVANCED management service was sent.



    Natural logarithm of output


    User name:
    SQL * Loader: release 11.2.0.1.0 - Production Friday, may 10, 15:55:15 2013

    Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.


    Loaded - the number of logical records 51.

    I usually run SQL * Loader of SQL * Plus, so that it avoids some of the questions of privilege. I also use a log file, so that I can check later to see what happened and why. For example:

    host sqlldr scott/tiger control = test.ctl log = test.log

    A common question is the lack of privileges for the data file to load. You can change an empty file in SQL * more and copy and paste the data into it, to eliminate such problems or identify them, so that you can check the privileges on the original file.

    To provide a lot of other things, we would need more information, such as a few lines of sample data, your SQL * Loader control file and the structure of your table.

  • SQL Loader with the line terminator

    Dear friends,

    I use Oracle 10 g R2.

    Need to load some records to a text file to Oracle.

    It's my control file:
    LOAD DATA 
    INFILE 'D:\load\dat\FinNote.dat' 
    BADFILE 'D:\load\bad\FinNote.bad' 
    DISCARDFILE 'D:\load\dat\discard\FinNote.dsc' 
    INSERT INTO TABLE FinNote FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING 
    NULLCOLS
    ( IDNo, RegDate date 'YYYY-MM-DD HH24:MI:SS', Col1, Remark, UserID, Status)
    {code}
    
    My text file has semicolon as a row delimiter and | as column delimiter. Now, how can I add the semicolon as row delimiter. Please guide me.
    
    I followed the method given in this site: 
    http://www.exforsys.com/tutorials/oracle-10g/oracle-10g-sql-loader-input-data-and-datafiles.html
    
    
    *INFILE datafile_name ["str terminator_string"]*
    
    {code}
    LOAD DATA 
    INFILE 'D:\load\dat\CRS_FinNote.dat' ";"
    BADFILE 'D:\load\bad\CRS_FinNote.bad' 
    DISCARDFILE 'D:\load\dat\discard\CRS_FinNote.dsc' 
    INSERT INTO TABLE CRS_FinNote FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING 
    
    NULLCOLS
    ( StudentNo, IDate date 'YYYY-MM-DD HH24:MI:SS', Topic, Remark, UserID, Status)
    and received the error:

    SQL * Loader-500: could not open the file (D:\load\dat\CRS_FinNote.dat)
    SQL * Loader-555: unrecognized property treatment option
    SQL * Loader-509: System error: the operation completed successfully.
    SQL * Loader-2026: the charge was dropped because SQL Loader cannot continue.
    SQL * Loader-513: cannot close the file (D:\load\dat\CRS_FinNote.dat)
    SQL * Loader-559: Error closing file
    SQL * Loader-509: System error: the storage control block address is invalid.

    Thanks in advance.
    Nith

    Published by: user645399 on June 16, 2010 10:35

    And, if your CRS_FinNote.dat look like below (line/record delimited; then)

    1245|2000-05-16|Oracle|The Best|AAA|Online;
    294|2000-04-03|Dotnet|Best|BBB|Pending;
    300|2010-03-28|C++|The Best|CCC|Offline;
    

    Scott@ORCL > select utl_raw.cast_to_raw (';') under "hexadecimal;" double;

    in hexadecimal
    --------------------------------------------------------------------------------
    3B

    Then I change user645399.ctl with below:

    LOAD DATA
    INFILE 'd:\csv\CRS_FinNote.dat' "str X'3B'"
    BADFILE 'd:\csv\FinNote.bad'
    DISCARDFILE 'd:\csv\FinNote.dsc'
    INSERT INTO TABLE FinNote FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING
    NULLCOLS
    ( IDNo, RegDate date 'YYYY-MM-DD HH24:MI:SS', Col1, Remark, UserID, Status)
    

    The idea received a link from http://www.orafaq.com/forum/t/140062/0/.

    C:\Documents and Settings\Girish Sharma>sqlldr scott/tiger@orcl control=d:\csv\user645399.ctl log=user645399.log
    
    Enter user-name: scott/tiger
    
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    
    SCOTT@orcl> select * from finnote;
    
          IDNO REGDATE              COL1       REMARK     USERID     STATUS
    ---------- -------------------- ---------- ---------- ---------- ----------
          1245 16-may-2000 00:00:00 Oracle     The Best   AAA        Online
           294 03-apr-2000 00:00:00 Dotnet     Best       BBB        Pending
           300 28-mar-2010 00:00:00 C++        The Best   CCC        Offline
    
    SCOTT@orcl>
    

    HTH
    Girish Sharma

  • How to handle multiple formats of date to the same date field in SQL * Loader

    Dear all,

    I have a requirement where I need to get data from a text file and even insert into the oracle table.

    I'm using SQL * Loader to fill data from the text file in my table.

    The file has an area where I expect to date data date in different formats, such as MON/dd/yyyy mon/dd/yyyy mon/dd/yyyy, dd/mm/yyyy, DD/month/yyyy.

    When you use SQL * Loader, I can see loading fails for records where we have formats such as LUN/jj/aaaa, Mon/dd/yyyy, DD/month/yyyy.

    Is it possible in SQL * Loader where we can mention all these date formats so that data from that date should go smoothly in the underlying date column in the table.

    Receive your answer on that.

    Thank you
    Madhu K.

    I think following could be the solution to your problem:

    Suppose if you have data from four different date formats, you need to load the data into four different tables by running SQL * Loader four times and each time specify other date format in the control file whose data to load, and then at the end, merge data from these four different tables using the UNION clause.

    Elya

  • When I started to update my iphone to ios 10 and watch 3.0, cannot already display the pictures of my watch. Logo of loading only. And he thinks it will take a hayss of 1000 years. Help, please

    When I started to update my iphone to ios 10 and watch 3.0, cannot already display the pictures of my watch. Logo of loading only. And he thinks it will take a hayss of 1000 years. Help, please

    Hello

    If the software on your watch is being updated, leave your watch and your iPhone until the process is complete (including the not remove your watch on the charger):

    Update the software on your Apple Watch - Apple Support

  • MONTH and YEAR functions.  Help, please...

    Can someone tell me why the YEAR and MONTH functions only accepts the format dd-MMM-yyyy (e.g. 1 January 2009)

    The guest of the calendar will be return only the format dd/mm/yyyy (e.g. 01/01/2009). This makes it pretty useless calendar.

    I really need help on this. Does anyone know how to get the value returned by the calendar in a command prompt in a format that can be used by the YEAR and MONTH functions?

    Thanks in advance

    Here's one without having to resort to assess:

    day: substring (' @{Date1} {01/01/1900}' of (locate('/','@{Date1}{01/01/1900}',1) + 1) for (locate ('/ ',' @{Date1} {01/01/1900}', 4)-locate('/','@{Date1}{01/01/1900}',1)-1))
    month: substring (' @{Date1} {01/01/1900}' of 1 for (locate ('/ ',' @{Date1} {01/01/1900}', 1)-1))
    year: substring (' @{Date1} {01/01/1900}' of (locate ('/ ',' @{Date1} {01/01/1900}', 4) + 1) for 4)

    in the format DD/MM/YYYY

    See also:
    http://obiee101.blogspot.com/2009/03/OBIEE-date-prompt-to-day-month-year.html

    concerning

    John
    http://obiee101.blogspot.com/

    Published by: John Minkjan, March 10, 2009 12:20 AM

  • Question to load data using sql loader in staging table, and then in the main tables!

    Hello

    I'm trying to load data into our main database table using SQL LOADER. data will be provided in separate pipes csv files.

    I have develop a shell script to load the data and it works fine except one thing.

    Here are the details of a data to re-create the problem.

    Staging of the structure of the table in which data will be filled using sql loader

    create table stg_cmts_data (cmts_token varchar2 (30), CMTS_IP varchar2 (20));

    create table stg_link_data (dhcp_token varchar2 (30), cmts_to_add varchar2 (200));

    create table stg_dhcp_data (dhcp_token varchar2 (30), DHCP_IP varchar2 (20));

    DATA in the csv file-

    for stg_cmts_data-

    cmts_map_03092015_1.csv

    WNLB-CMTS-01-1. 10.15.0.1

    WNLB-CMTS-02-2 | 10.15.16.1

    WNLB-CMTS-03-3. 10.15.48.1

    WNLB-CMTS-04-4. 10.15.80.1

    WNLB-CMTS-05-5. 10.15.96.1

    for stg_dhcp_data-

    dhcp_map_03092015_1.csv

    DHCP-1-1-1. 10.25.23.10, 25.26.14.01

    DHCP-1-1-2. 56.25.111.25, 100.25.2.01

    DHCP-1-1-3. 25.255.3.01, 89.20.147.258

    DHCP-1-1-4. 10.25.26.36, 200.32.58.69

    DHCP-1-1-5 | 80.25.47.369, 60.258.14.10

    for stg_link_data

    cmts_dhcp_link_map_0309151623_1.csv

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    DHCP-1-1-2. WNLB-CMTS-03-3,WNLB-CMTS-04-4,WNLB-CMTS-05-5

    DHCP-1-1-3. WNLB-CMTS-01-1

    DHCP-1-1-4. WNLB-CMTS-05-8,WNLB-CMTS-05-6,WNLB-CMTS-05-0,WNLB-CMTS-03-3

    DHCP-1-1-5 | WNLB-CMTS-02-2,WNLB-CMTS-04-4,WNLB-CMTS-05-7

    WNLB-DHCP-1-13 | WNLB-CMTS-02-2

    Now, after loading these data in the staging of table I have to fill the main database table

    create table subntwk (subntwk_nm varchar2 (20), subntwk_ip varchar2 (30));

    create table link (link_nm varchar2 (50));

    SQL scripts that I created to load data is like.

    coil load_cmts.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_cmts IS SELECT *.

    OF stg_cmts_data;

    TYPE t_stg_cmts IS TABLE OF stg_cmts_data % ROWTYPE INDEX BY pls_integer;

    l_stg_cmts t_stg_cmts;

    l_cmts_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_cmts.

    Get the c_stg_cmts COLLECT in BULK IN l_stg_cmts;

    BECAUSE me IN l_stg_cmts. FIRST... l_stg_cmts. LAST

    LOOP

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_cmts (i) .cmts_token;

    IF l_cmts_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_cmts (i) .cmts_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_cmts (i) .cmts_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_cmts EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for dhcp


    coil load_dhcp.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_dhcp IS SELECT *.

    OF stg_dhcp_data;

    TYPE t_stg_dhcp IS TABLE OF stg_dhcp_data % ROWTYPE INDEX BY pls_integer;

    l_stg_dhcp t_stg_dhcp;

    l_dhcp_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_dhcp.

    Get the c_stg_dhcp COLLECT in BULK IN l_stg_dhcp;

    BECAUSE me IN l_stg_dhcp. FIRST... l_stg_dhcp. LAST

    LOOP

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_dhcp (i) .dhcp_token;

    IF l_dhcp_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_dhcp (i) .dhcp_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_dhcp (i) .dhcp_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_dhcp EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for link -.

    coil load_link.log

    Set serveroutput on

    DECLARE

    l_cmts_1 VARCHAR2 (4000 CHAR);

    l_cmts_add VARCHAR2 (200 CHAR);

    l_dhcp_cnt NUMBER;

    l_cmts_cnt NUMBER;

    l_link_cnt NUMBER;

    l_add_link_nm VARCHAR2 (200 CHAR);

    BEGIN

    FOR (IN) r

    SELECT dhcp_token, cmts_to_add | ',' cmts_add

    OF stg_link_data

    )

    LOOP

    l_cmts_1: = r.cmts_add;

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = r.dhcp_token;

    IF l_dhcp_cnt = 0 THEN

    DBMS_OUTPUT. Put_line ("device not found: ' |") r.dhcp_token);

    ON THE OTHER

    While l_cmts_add IS NOT NULL

    LOOP

    l_add_link_nm: = r.dhcp_token |' _TO_' | l_cmts_add;

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = TRIM (l_cmts_add);

    SELECT COUNT (1)

    IN l_link_cnt

    LINK

    WHERE link_nm = l_add_link_nm;

    IF l_cmts_cnt > 0 AND l_link_cnt = 0 THEN

    INSERT INTO link (link_nm)

    VALUES (l_add_link_nm);

    DBMS_OUTPUT. Put_line (l_add_link_nm |) » '||' Has been added. ") ;

    ELSIF l_link_cnt > 0 THEN

    DBMS_OUTPUT. Put_line (' link is already present: ' | l_add_link_nm);

    ELSIF l_cmts_cnt = 0 then

    DBMS_OUTPUT. Put_line (' no. CMTS FOUND for device to create the link: ' | l_cmts_add);

    END IF;

    l_cmts_1: = TRIM (SUBSTR (l_cmts_1, INSTR (l_cmts_1, ',') + 1));

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    END LOOP;

    END IF;

    END LOOP;

    COMMIT;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    control files -

    DOWNLOAD THE DATA

    INFILE 'cmts_data.csv '.

    ADD

    IN THE STG_CMTS_DATA TABLE

    When (cmts_token! = ") AND (cmts_token! = 'NULL') AND (cmts_token! = 'null')

    and (cmts_ip! = ") AND (cmts_ip! = 'NULL') AND (cmts_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:cmts_token))' cmts_token,

    cmts_ip ' RTRIM (LTRIM(:cmts_ip)) ")". "

    for dhcp.


    DOWNLOAD THE DATA

    INFILE 'dhcp_data.csv '.

    ADD

    IN THE STG_DHCP_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (dhcp_ip! = ") AND (dhcp_ip! = 'NULL') AND (dhcp_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    dhcp_ip ' RTRIM (LTRIM(:dhcp_ip)) ")". "

    for link -.

    DOWNLOAD THE DATA

    INFILE 'link_data.csv '.

    ADD

    IN THE STG_LINK_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (cmts_to_add! = ") AND (cmts_to_add! = 'NULL') AND (cmts_to_add! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    cmts_to_add TANK (4000) RTRIM (LTRIM(:cmts_to_add)) ")" ""

    SHELL SCRIPT-

    If [!-d / log]

    then

    Mkdir log

    FI

    If [!-d / finished]

    then

    mkdir makes

    FI

    If [!-d / bad]

    then

    bad mkdir

    FI

    nohup time sqlldr username/password@SID CONTROL = load_cmts_data.ctl LOG = log/ldr_cmts_data.log = log/ldr_cmts_data.bad DISCARD log/ldr_cmts_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    nohup time username/password@SID @load_cmts.sql

    nohup time sqlldr username/password@SID CONTROL = load_dhcp_data.ctl LOG = log/ldr_dhcp_data.log = log/ldr_dhcp_data.bad DISCARD log/ldr_dhcp_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_dhcp.sql

    nohup time sqlldr username/password@SID CONTROL = load_link_data.ctl LOG = log/ldr_link_data.log = log/ldr_link_data.bad DISCARD log/ldr_link_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_link.sql

    MV *.log. / log

    If the problem I encounter is here for loading data in the link table that I check if DHCP is present in the subntwk table, then continue to another mistake of the newspaper. If CMTS then left create link to another error in the newspaper.

    Now that we can here multiple CMTS are associated with unique DHCP.

    So here in the table links to create the link, but for the last iteration of the loop, where I get separated by commas separate CMTS table stg_link_data it gives me log as not found CMTS.

    for example

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    Here, I guess to link the dhcp-1-1-1 with balancing-CMTS-01-1 and wnlb-CMTS-02-2

    Theses all the data present in the subntwk table, but still it gives me journal wnlb-CMTS-02-2 could not be FOUND, but we have already loaded into the subntwk table.

    same thing is happening with all the CMTS table stg_link_data who are in the last (I think here you got what I'm trying to explain).

    But when I run the SQL scripts in the SQL Developer separately then it inserts all valid links in the table of links.

    Here, she should create 9 lines in the table of links, whereas now he creates only 5 rows.

    I use COMMIT in my script also but it only does not help me.

    Run these scripts in your machine let me know if you also get the same behavior I get.

    and please give me a solution I tried many thing from yesterday, but it's always the same.

    It is the table of link log

    link is already present: dhcp-1-1-1_TO_wnlb-cmts-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-02-2

    link is already present: dhcp-1-1-2_TO_wnlb-cmts-03-3
    link is already present: dhcp-1-1-2_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-5

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-8
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-6
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-0

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-03-3

    link is already present: dhcp-1-1-5_TO_wnlb-cmts-02-2
    link is already present: dhcp-1-1-5_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-7

    Device not found: wnlb-dhcp-1-13

    IF NEED MORE INFORMATION PLEASE LET ME KNOW

    Thank you

    I felt later in the night that during the loading in the staging table using UNIX machine he created the new line for each line. That is why the last CMTS is not found, for this I use the UNIX 2 BACK conversion and it starts to work perfectly.

    It was the dos2unix error!

    Thank you all for your interest and I may learn new things, as I have almost 10 months of experience in (PLSQL, SQL)

  • Pls help: SQL Loader support only a single record

    Hello!!!

    I'm trying to insert data into a table using SQL Loader.

    I entered on the command line,

    > sqlldr userid = abc\abc control = "contrl_file_name.ctl."

    It does not perform any operation and simply crashes... table does no data... no data in the log file...

    It simply shows the SQL Loader Release... production... Copyright messages and do not stop.

    Am new on SQL loader... Kindly help

    *************************************************************

    Another problem:

    I have my file loading_data.dat with multiple entries as below which are records to be inserted for a single column in my table.

    233207332711 < EOFD > < EORD > 233208660745 < EOFD > < EORD > 233200767380 < EOFD > < EORD >...

    My control file is like this:

    data continue_load

    INFILE loading_data.dat '.

    Insert

    in table T1

    fields terminated by '< EOFD > < EORD >.

    (msisdn)

    When I execute the following statement of sqlldr, he inserts a single record and says loading completed - logical number of records 1.

    Why my other documents are not get inserted?

    Post edited by: 3cd7ad85-b56c-4a9c-ae91-83be047aac2c

    Continue_load can only be used with direct path, unconventional path.  You must specify the record terminator and terminator of field, which is the same when your data are only a single column.  Please see the example below.  As for your digital problem, as you can see, it does not reproduce below.  Your problem could be due to many things.  He might try to read something else that what you think, he tries to read, because of something else being wrong.  It is possible that you need to use:

    (msisdn "to_number (ltrim (rtrim (: msisdn)))")

    to remove the leading and trailing spaces and convert it to a number.  You must provide a copy and pasting a full example, as I did below.

    -loading_data.dat content:

    233207332711 233208660745 233200767380

    -control_file_name.ctl:

    load data

    INFILE loading_data.dat "str"".

    Insert

    in table T1

    fields terminated by ' '.

    (msisdn)

    Scott@orcl12c_11gR2 > create table t1 (msisdn number)

    2.

    Table created.

    Scott@orcl12c_11gR2 > host sqlldr scott/tiger control = control_file_name.ctl log = test.log

    Scott@orcl12c_11gR2 > numLargeur 20 the value

    Scott@orcl12c_11gR2 > select * from t1

    2.

    MSISDN

    --------------------

    233207332711

    233208660745

    233200767380

    3 selected lines.

Maybe you are looking for