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

Tags: Database

Similar Questions

  • 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.

  • 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]

  • 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;

  • 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.

  • Need help with SQL Loader

    I have a third-party site that transforms the information into a csv summary. I can't change the format, and they are not ready to give directly from db and db, so I try and then import it. I'm trying to use SQL Loader, but I can't seem to make it work. I looked in the documentation (VERY rare examples) as well as several websites and I can't find anything that can help out me.

    Control file:
    LOAD DATA
    INFILE 'Daily_Diagnostics_test.csv'
    BADFILE 'Diag_failed.csv'
    APPEND
    INTO TABLE ROAD_DIAGS
    FIELDS TERMINATED BY ","
    --WHEN VEHICLE != 'Vehicle' AND VEHICLE != 'Total'
    (VEHICLE, DRIVER, START_DATE, START_TIME, START_TZ, END_DATE, END_TIME, END_TZ, 
     TM_DRV_MINS, TM_IDLE_MINS, TM_PTO_MINS, TRIP_TM_MINS,
     FUEL_DRV_GALS, FUEL_IDLE_GALS, FUEL_PTO_GALS, FUEL_TRIP_GALS, FUEL_START_GALS,
     MPG, DRV_MPG, START_ODOM, END_ODOM, DIFF_ODOM, AVG_MPH, MAX_MPH, MAX_RPM,
     DATE1, TM1, TZ1, ADDRESS_NUM1, ADDRESS_STREET1, ADDRESS_ST1, ADDRESS_ZIP1, ADDRESS_COUNTY1,
     DATE2, TM2, TZ2, ADDRESS_NUM2, ADDRESS_STREET2, ADDRESS_ST2, ADDRESS_ZIP2, ADDRESS_COUNTY2,
     STOP_CT, FAULT_CODE, HARD_BRAKE)
    Note that the line WHEN is commented out, because I can't make it work.

    and here is a sample of the data:
    Vehicle,Driver,Start Date,Start Time,Timezone,End Date,End Time,Timezone,Driving (hh:mm),Idle (hh:mm),PTO (hh:mm),Trip (hh:mm),Driving (gals),Idle (gals),PTO (gals),Trip (gals),Before Trip (gals), MPG,Driving MPG,Start,End,Trip Distance (miles),Average(MPH),Maximum(MPH),Maximum RPM(rpm),Date,Time,Timezone,Address,Street,City,State,Zip,County,Date,Time,Timezone,Address,Street,City,State,Zip,County,Stop Count,Fault Code,Hard Brake,
    26033, ,01/23/08,12:40 AM,MST,01/23/08,12:42 AM,MST,0,3,0,3,0,0.12,0,0.12, ,0,0,295829.22,295829.22,0,0,6.84, ,01/23/08,12:23 AM,MST,0,COUNTY ROAD 108,SAVAGE,MT,59262,RICHLAND,01/23/08,12:23 AM,MST,0,COUNTY ROAD 108,SAVAGE,MT,59262,RICHLAND,0,4, ,
    26033, ,01/23/08,12:43 AM,MST,01/23/08,04:03 AM,MST,126,74,0,200,0,0,0,0, ,0,0,295829.22,295914.97,85.75,25.72,67.11, ,01/23/08,12:23 AM,MST,0,COUNTY ROAD 108,SAVAGE,MT,59262,RICHLAND,01/23/08,03:56 AM,MST,0,COUNTY ROAD 125,SIDNEY,MT,59270,RICHLAND,8,3, ,
    26033, ,01/23/08,04:03 AM,MST,01/23/08,12:29 PM,MST,317,190,0,507,0,0,0,0, ,0,0,295914.97,296139.9,224.94,26.64,65.87, ,01/23/08,03:56 AM,MST,0,COUNTY ROAD 125,SIDNEY,MT,59270,RICHLAND,01/23/08,12:29 PM,MST,756,BELL RD,SIDNEY,MT,59270,RICHLAND,14,5, ,
    Total, , , ,443,267,0,710,0,0.12,0,0.12, ,0,0,295829.22,296139.91,310.69,26.38,67.11, , , , , , , , , , , , , , , , , , , ,22,12,0,
    Vehicle,Driver,Start Date,Start Time,Timezone,End Date,End Time,Timezone,Driving (hh:mm),Idle (hh:mm),PTO (hh:mm),Trip (hh:mm),Driving (gals),Idle (gals),PTO (gals),Trip (gals),Before Trip (gals), MPG,Driving MPG,Start,End,Trip Distance (miles),Average(MPH),Maximum(MPH),Maximum RPM(rpm),Date,Time,Timezone,Address,Street,City,State,Zip,County,Date,Time,Timezone,Address,Street,City,State,Zip,County,Stop Count,Fault Code,Hard Brake,
    26035, ,01/23/08,03:59 AM,MST,01/23/08,09:05 AM,MST,222,85,0,306,50.87,1.5,0,52.37, ,3.32,3.42,285056.53,285230.5,173.98,34.07,68.97, ,01/23/08,03:24 AM,MST,756,BELL RD,SIDNEY,MT,59270,RICHLAND,01/23/08,09:00 AM,MST,0,COUNTY ROAD 338,SAVAGE,MT,59262,RICHLAND,7,3, ,
    26035, ,01/23/08,09:06 AM,MST,01/23/08,03:37 PM,MST,273,118,0,391,68.5,1.5,0,70, ,3.24,3.31,285230.5,285457.3,226.8,34.8,69.59, ,01/23/08,09:00 AM,MST,0,COUNTY ROAD 338,SAVAGE,MT,59262,RICHLAND,01/23/08,03:37 PM,MST,756,BELL RD,SIDNEY,MT,59270,RICHLAND,11,3, ,
    26035, ,01/23/08,03:45 PM,MST,01/23/08,04:38 PM,MST,32,21,0,53,7.37,0.25,0,7.62, ,3.42,3.54,285457.3,285483.4,26.1,29.73,67.73, ,01/23/08,03:37 PM,MST,756,BELL RD,SIDNEY,MT,59270,RICHLAND,01/23/08,04:33 PM,MST,0,COUNTY ROAD 108,SAVAGE,MT,59262,RICHLAND,2,3, ,
    26035, ,01/23/08,04:49 PM,MST,01/23/08,10:22 PM,MST,256,76,0,332,52,1.25,0,53.25, ,3.71,3.8,285483.4,285681.0,197.6,35.67,64, ,01/23/08,04:33 PM,MST,0,COUNTY ROAD 108,SAVAGE,MT,59262,RICHLAND,01/23/08,10:17 PM,MST,0,COUNTY ROAD 108,SAVAGE,MT,59262,RICHLAND,9,3, ,
    26035, ,01/23/08,10:25 PM,MST,01/23/08,10:35 PM,MST,4,5,0,10,0.37,0,0,0.37, ,1.68,1.68,285681.0,285681.62,0.62,3.9,24.85, ,01/23/08,10:17 PM,MST,0,COUNTY ROAD 108,SAVAGE,MT,59262,RICHLAND,01/23/08,10:35 PM,MST,0,COUNTY ROAD 338,SAVAGE,MT,59262,RICHLAND,1,5, ,
    Total, , , ,787,305,0,1092,179.11,4.5,0,183.61, ,3.4,3.49,285056.53,285681.62,625.1,34.35,69.59, , , , , , , , , , , , , , , , , , , ,30,17,0,
    As you can see, I need to have the SQL Loader to ignore the header and summary lines that appear for each grouping. Your suggestions are welcome as I need to implement this in an automatic process, I can call with a batch script.

    blarman74 wrote:
    Can anyone suggest how to fix this problem? The log file shows this error:

    Record 8: Rejected - Error on table ROAD_DIAGS, column DATE2.
    ORA-01858: a non-numeric character was found where a numeric was expected
    

    The error message is clear - you try to load a value "non-date" in a DATE column and, therefore, sql * loader berms.
    That points to a discrepancy between the list of columns in the control file and, in the data file.
    Note the position of the table of the "DATE2" column in the table "ROAD_DIAGS":

    test@XE>
    test@XE> l
      1  select table_name,
      2         column_name,
      3         column_id
      4    from user_tab_columns
      5   where table_name='ROAD_DIAGS'
      6*    and column_name='DATE2'
    test@XE> /
    
    TABLE_NAME      COLUMN_NAME      COLUMN_ID
    --------------- --------------- ----------
    ROAD_DIAGS      DATE2                   34
    
    test@XE>
    

    If your control file specifies that the 34th column in the data file must be "DATE2". However-

    test@XE>
    test@XE> -- display the line number and the 34th column of the data file
    test@XE>
    test@XE> !perl -ne '{@a=split/,/; print $.,"\t",$a[33],"\n"}' Daily_Diagnostics_test.csv
    1       County
    2       RICHLAND
    3       RICHLAND
    4       RICHLAND
    5
    6       County
    7       RICHLAND
    8       RICHLAND
    9       RICHLAND
    10      RICHLAND
    11      RICHLAND
    12
    
    test@XE>
    

    the 34th column in your data file is 'COUNTY', which is counted in your control file.

    Here is the list of the columns for 29 to 37 positions in the csv file:

    test@XE>
    test@XE> !perl -ne '{if ($. == 1) {@a=split/,/; foreach $i (28..36) {print $i+1,"\t",$a[$i],"\n"}}}' Daily_Diagnostics_test.csv
    29      Address
    30      Street
    31      City
    32      State
    33      Zip
    34      County
    35      Date
    36      Time
    37      Timezone
    
    test@XE>
    test@XE>
    

    And here are the columns specified in the control file:

      ...
      ...
      ADDRESS_NUM1,
      ADDRESS_STREET1,
      ADDRESS_ST1,
      ADDRESS_ZIP1,
      ADDRESS_COUNTY1,
      DATE2            DATE "MM/DD/YYYY",
      TM2              DATE "HH:MI AM",
      TZ2,
      ...
      ...
    

    (You can open the csv file in MS Excel to get a better picture of the data in there).

    As seen above, due to the incompatibility, sql * loader loads 'City' in ADDRESS_ST1, 'State' in ADDRESS_ZIP1, "Zip" in ADDRESS_COUNTY1 and DATE2 "County" - where it error.

    The solution would be-

    (a) If you want to load the 'City' information from the data file, and then add the "City" column in the table (if nonexistent) and specify in the control file.

    (b) If you do not want to load the 'City' information from the data file, you can specify a column to 'FILL' in the file of control as follows:

      ...
      ...
      ADDRESS_NUM1,
      ADDRESS_STREET1,
      city1            FILLER,
      ADDRESS_ST1,
      ADDRESS_ZIP1,
      ADDRESS_COUNTY1,
      DATE2            DATE "MM/DD/YYYY",
      TM2              DATE "HH:MI AM",
      TZ2,
      ADDRESS_NUM2,
      ADDRESS_STREET2,
      city2            FILLER,
      ADDRESS_ST2,
      ADDRESS_ZIP2,
      ADDRESS_COUNTY2,
      ...
      ...
    

    Hope that helps,
    isotope

  • Need help about sql loader

    Hello

    I will execute following command

    sqlldr admin_user@ces CONTROL = D:\sample_control.ctl log = D:\sample_log.log D:\Sample_bad.bad = bad

    In the case of valid data, it's inserted data properly into the table. While no valid records added in the wrong file.

    Now I want to restore whenever valid data that the number of bad record greater than equal to 10.

    In short, whenever the file has more than 10 invalid records, I don't want to insert any record of this file.

    Please give me the solution. Thanks in advance.

    SQL * Loader command line reference

    DISCARDMAX (Integer)

    Concerning

    Etbin

  • Reference SQL Loader Bind Variables in the when Clause

    Support for SQL: SQL * Loader: version 8.0.6.3.0 (don't ask, it runs on Oracle EBS 11i...)

    I have a case where my sample data looks like:
    HD00100001002
    SM00100002CHAPS   99999999999                     20120906GBP0000000000001000000000001
    and another file
    HD00100001001
    SM00100002GBP0000000000001000000000001
    Essentially, I need to apply another "IN" clause for each record of SM depends on the ack_type (char 13 on HD recording), either 1 or 2

    I tried setting up the ack_type with a variable binding but find how to reference.

    Example of control file:
    --  $Header: test.ctl
    --
    
    LOAD DATA
    REPLACE
    
    -- Record Type HD : File Header
    INTO TABLE  test_table
    WHEN rec_id_no = 'HD'
    TRAILING NULLCOLS
    (rec_no                 RECNUM,
     hdr_line               CONSTANT 'H',
     rec_id_no              POSITION(1:2)   CHAR,
     file_number            POSITION(3:5)   CHAR,
     sequence_number        POSITION(6:10)  CHAR,
     status                 POSITION(11:12) CHAR,
     ack_type               POSITION(13:13) ":ack_type",
     co_id                  POSITION(14:21) CHAR,
     dept_id                POSITION(22:24) CHAR,
     btch_no                POSITION(25:36) CHAR,
     trans_id               POSITION(37:42) CHAR)
    
    -- Record Type SM : File Summary
    INTO TABLE test_table
    WHEN rec_id_no = 'SM' and :ack_type = '1'
    TRAILING NULLCOLS
    (rec_no                 RECNUM,
     hdr_line               CONSTANT 'L',
     rec_id_no              POSITION(1:2)   CHAR,
     file_number            POSITION(3:5)   CHAR,
     sequence_number        POSITION(6:10)  CHAR,
     ccy_code               POSITION(11:13) CHAR,
     amount                 POSITION(14:26) CHAR,
     number_trans_ok        POSITION(27:40) CHAR)
    The code above does not work, it is said that: ack_type is not recognized. Is there a way to do it, given the former character of the SQL Load version?

    What is the database version 11i is running on? If 11 GR 2, this doc can help you in the use of the features that Dan mentions

    How to use the 9i or 10g features in SQL * Loader for Apps? [423035.1 ID]

    HTH
    Srini

  • Error loading XML file in the column of XMLTYPE through SQL loader

    Hi gurus,

    I am trying to load the XML file into the column of XMLTYPE through SQL Loader but the errors themselves. Here are the details

    Databases
    SQL*Plus: Release 10.2.0.3.0 - Production on Tue Jul 24 17:17:55 2012
    
    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
    
    
    Connected to:
    Oracle Database 10g Release 10.2.0.3.0 - 64bit Production
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Release 10.2.0.3.0 - 64bit Production
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for Linux: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    The table structure
    CREATE TABLE TH_XML
    (
      COL_ID_1   VARCHAR2(100 BYTE),
      IN_FILE_1  XMLTYPE
    )
    XMLTYPE IN_FILE_1 STORE AS CLOB (TABLESPACE SMDAT)
    XML (simple.xml) file
    <?xml version="1.0"?>
     <catalog> 
     <book id="bk101"> 
               <author>Some Author1</author> 
               <title>Some Title1</title> 
               <genre>Computer</genre> 
               <price>44.95</price> 
               <publish_date>2000-10-01</publish_date> 
               <description>creating applications</description> 
       </book> 
       <book id="bk112"> 
               <author>Some Author2</author> 
               <title>Some Title2</title> 
               <genre>Computer</genre> 
               <price>49.95</price> 
               <publish_date>2001-04-16</publish_date> 
               <description>Microsoft Visual Studio 7 is explored in depth</description> 
    </book> 
    </catalog>
    Control file
    LOAD DATA
    INFILE 'c:\simple.xml'
    APPEND
    INTO TABLE TH_XML 
    XMLTYPE(in_file_1)
    (
    col_id_1 filler  CHAR (100),
    in_file_1 LOBFILE(CONSTANT "c:\simple.xml") TERMINATED BY EOF
    )
    LOG file
    SQL*Loader: Release 10.2.0.3.0 - Production on Tue Jul 24 16:42:25 2012
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Control File:   c:\my_file.ctl
    Data File:      c:\simple.xml
      Bad File:     c:\simple.bad
      Discard File:  none specified
     
     (Allow all discards)
    
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array:     64 rows, maximum of 256000 bytes
    Continuation:    none specified
    Path used:      Conventional
    
    Table TH_XML, loaded from every logical record.
    Insert option in effect for this table: APPEND
    
       Column Name                  Position   Len  Term Encl Datatype
    ------------------------------ ---------- ----- ---- ---- ---------------------
    COL_ID_1                            FIRST   100           CHARACTER            
      (FILLER FIELD)
    IN_FILE_1                         DERIVED     *  EOF      CHARACTER            
        Static LOBFILE.  Filename is c:\simple.xml
    
    Record 1: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 2: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 3: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 4: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 5: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 6: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 7: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 8: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 9: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 10: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 11: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 12: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 13: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 14: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 15: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 16: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 17: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 18: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 19: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 20: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 21: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 22: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    Record 23: Rejected - Error on table TH_XML.
    ORA-00904: "SYS_NC_ROWINFO$": invalid identifier
    
    
    Table TH_XML:
      0 Rows successfully loaded.
      23 Rows not loaded due to data errors.
      0 Rows not loaded because all WHEN clauses were failed.
      0 Rows not loaded because all fields were null.
    
    
    Space allocated for bind array:                    256 bytes(64 rows)
    Read   buffer bytes: 1048576
    
    Total logical records skipped:          0
    Total logical records read:            23
    Total logical records rejected:        23
    Total logical records discarded:        0
    
    Run began on Tue Jul 24 16:42:25 2012
    Run ended on Tue Jul 24 16:42:26 2012
    
    Elapsed time was:     00:00:00.23
    CPU time was:         00:00:00.05
    I get error ORA-00904: "SYS_NC_ROWINFO$": invalid identifier in the logfile (mentioned above). Could someone help me know where I am doing wrong?

    Thanks in advance.

    Published by: 876991 on 24 July 2012 14:18

    Hello

    This remove the control file:

    XMLTYPE(in_file_1)
    

    It is used only if the target table is an array of XMLType object.

    For an XMLType column LOBFILE is sufficient, for example:

    LOAD DATA
    INFILE *
    APPEND INTO TABLE TH_XML
    (
     col_id_1  CHAR (100),
     in_file_1 LOBFILE(CONSTANT "c:\simple.xml") TERMINATED BY EOF
    )
    begindata
    MYID1
    

    It tells SQL * Loader data consisting of one record with COL_ID_1 = "MYID1" and content = "c:\simple.xml" IN_FILE_1

    SQL> CREATE TABLE TH_XML
      2  (
      3    COL_ID_1   VARCHAR2(100 BYTE),
      4    IN_FILE_1  XMLTYPE
      5  );
    
    Table created.
    
    SQL> host sqlldr control=test.ctl
    Username:dev
    Password:
    
    SQL*Loader: Release 11.2.0.2.0 - Production on Mer. Juil. 25 01:30:46 2012
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    Commit point reached - logical record count 1
    
    SQL> set long 5000
    SQL> column col_id_1 format a15
    SQL> select * from th_xml;
    
    COL_ID_1        IN_FILE_1
    --------------- --------------------------------------------------------------------------------
    MYID1           
                     
                     
                               Some Author1
                               Some Title1
                               Computer
                               44.95
                               2000-10-01
                               creating applications
                       
                       
                               Some Author2
                               Some Title2
                               Computer
                               49.95
                               2001-04-16
                               Microsoft Visual Studio 7 is explored in depth
                    
     
    
  • Syntax SQL LOADER

    Hi guru. !!!

    can someone tell me abt advantage of charger sq in 11g on sql loader in 10g... !!!

    Please help me with this... !!!

    user13490153 wrote:
    Hi guru. !!!

    can someone tell me abt advantage of charger sq in 11g on sql loader in 10g... !!!

    Please help me with this... !!!

    not sure, there is really no version 11 g and 10g n/b difference!

    Better would be to use external tables.

    http://www.morganslibrary.org/reference/externaltab.html

    ... and keep all your processing in the database rather than from the command line.

  • 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)

  • SQL Loader - null is not recognized

    Hi, I have a very strange question that I would really appreciate help with.

    We have the file following sql ctl charger that works very well.

    OPTIONS (DIRECT = TRUE, PARALLEL = FALSE, ERRORS = 0, BINDSIZE = 50000, LINES = 10000, READ)

    SIZE = 65536)

    DOWNLOAD THE DATA

    CHARACTERSET WE8MSWIN1252

    INFILE 'file1' "STR X ' 0 and has.

    READBUFFERS 4

    IN THE TABLE test.tabl1

    TRUNCATE

    REACTIVATE THE DISABLED_CONSTRAINTS

    FIELDS

    (

    POSITION TANK (01:25) "DT_TM_ADDED" "DECODE (SUBSTR (: DT_TM_ADDED, 13.2), null,).

    Substr(:dt_tm_added,1,11) | "(00:00:00 ',: DT_TM_ADDED) ' etc. .

    We must now change our ctl files so the fields are completed by |

    It now looks like this.

    FIELDS TERMINATED BY ' |'

    (

    "DT_TM_ADDED" TANK "DECODE (SUBSTR (: DT_TM_ADDED, 13.2), null, substr(:dt_tm_add)).

    Ed, 1, 11). 00:00:00',TRIM(:DT_TM_ADDED)) ", etc.

    This works great besides when the DT_TM_ADDED, 13.2 has a value zero. Its not picking up that it is worth zero. If I change the statement as follows using a ' ' instead of null, IE (: DT_TM_ADDED, 13.2), ' ', substr,... it works very well.


    Am I missing something really obvious here?

    Any help would be really appreciated.

    Morgan Library has great demos on SQL LOADER.

    Demo 6

    "Use keywords NULLIF and DRAFTS to manage a length no strings loaded into numeric columns. Also note the use of the Direct path load in the control file (DIRECT = TRUE). »

    Link: Oracle 12 c SQL * Loader

    It could be that useful...

  • SQL loader is loading only one record

    I use SQL loader to load a CSV file into database

    sqlldr CON CONTROL = 'test.ctl' = 'TEST.log' = bad "bad.bad" LOG DATA = ' test. DAT'

    How ever I always only one record

    CTL file

    OPTIONS (ERRORS = 50)

    DOWNLOAD THE DATA

    ADD

    CONTINUEIF NEXT(1:1) = ' # '.

    IN TABLEtest

    FIELDS TERMINATED BY' '

    SURROUNDED OF POSSIBLY ' "" ' AND ' "'"

    TRAILING NULLCOLS)

    "Etest_ID" (27) TANK.

    'test_IND' CHAR (8),

    'test_SUB_IND' CHAR (12),

    "test_GIND1" TANK (9).

    "test_GIND2" TANK (9).

    'test_STATUS' CHAR (11),

    'test_STATUS' CHAR (11),

    'test_AMOUNT1' CHAR (14).

    'test_AMOUNT2' CHAR (14).

    'test_AMOUNT3' CHAR (14).

    'test_AMOUNT4' CHAR (14).

    "test_GIND21" TANK (9).

    "tet_GIND3" TANK (9).

    'test_STATUS1' CHAR (11),

    'test_STATUS2' CHAR (11),

    'test_AMOUNT1' CHAR (14).

    'test_AMOUNT2' CHAR (14).

    "test_FLAG" TANK (9).

    'test_USED_FLAG' CHAR (15).

    "test_FLAG" TANK (9).

    'TtestL_TRF_AMOUNT' CHAR (16).

    'testF_DATE' CHAR (8),

    'test_STATUS' CHAR (14))

    data file

    'AB00431MT00377_110915_00000 '."PP"."    "« Y »« Y »'TRAN '."FAILURE."'00000008667.15 '.'00000000000.00 '.'00000000000.00 '.'00000000000.00 '.« Y »« Y »'ZERO '.'ZERO '.'00000000000.00 '.'00000000000.00 '.« Y »« Y »" "'00000008667.15 '.'2111014 '.« S »
    'AB00431MT00377_110915_00000 '."PP"."    "« Y »" "'ZERO '."    "'00000000000.00 '.'00000000000.00 '.'00000000000.00 '.'00000000000.00 '.« Y »" "'ZERO '."    "'00000000000.00 '.'00000000000.00 '.« Y »" "" "'00000000000.00 '."0000000".« R »

    Help, please

    I tried generating CTL gall in various Noah this option worked. It is urgent please help

  • Name of dynamic INFILE SQL loader

    Hi all

    I use oracle 10g on windows server.

    I have a log on a remote server. each line in the log file is as below

    LogIN Mar 02/09/2014 10:10:48 ss18 N419FS40 1

    I create a table for that as below;

    Create table free_pc (log_in varchar2(10),log_day varchar2(10),log_date date,log_time date,log_user varchar2(30),log_Lab varchar2(30),log_pc varchar2(30), log_status char(1));
    

    I have two problems;

    1 N419FS40, the N419 is the name of a student in the lab, while FS40 is the name of the computer in this laboratory. I want only the first four characters to be inserted into the column of Log_lab and the rest of characters iin Log_pc column. my control file is less than

    DOWNLOAD THE DATA

    INFILE '\\remote_location\login02_09_14.txt '.

    ADD

    IN THE TABLE free_pc

    FIELDS FINISHED WITH A WHITE SPACE

    (log_in,

    log_day,

    log_date DATE "DD/MM/YYYY",

    log_time DATE "HH24 MI SS."

    LOG_USER,

    log_Lab,

    log_PC,

    log_status

    )

    How to do this?

    2. the log file is generated on the server, every day with a different name, he cancatenate the current date with Word LOGIN, for example login02_09_14.txt, login03_09_14.txt and login04_09_14 etc. in my INFILE tag, how can I put the name, so that it automatically take the name of the remote location?

    Thank you.

    Kind regards.

    1. you can use the SUBSTR function to separate the two values.  You put the fields in the control file in the same order in the data file, with all the columns that are formulated from data in other areas at the end.

    2. There are different ways to do this.  The file name can be in the control file or the SQL * Loader command line.  You can create either using SQL/SQL * Plus or operating system commands.  I tend to prefer change just the line of SQL * Loader command line, instead of the entire control file.  I prefer to do this in a SQL file instead of a file breaks Windows or * ix shell script or something, so that it is independent of the operating system.

    In addition, it is best to store all of your day, date and time in a column, then you can use to_char to display it as you want, in a column, or two or three.

    Please see the example below, in which I have shown above.

    Scott@ORCL >-data file you provided with the name changed to include today's date:

    Scott@ORCL > HOST TYPE 'c:\remote_location\login27_04_15.txt '.

    Opening on Tuesday, September 2, 2014 ss18 N419FS40 1 10:10:48

    Scott@ORCL >-control file with no infile, fields in the order of the data file, using fill for the unused columns,.

    Scott@ORCL >-with forumulated columns, using boundfiller for filling necessary for columns columns drawn up:

    Scott@ORCL > test.ctl TYPE of HOST

    DOWNLOAD THE DATA

    ADD

    IN THE TABLE free_pc

    FIELDS FINISHED WITH A WHITE SPACE

    TRAILING NULLCOLS

    (log_in,

    log_day FILLING,

    log_date BOUNDFILLER,

    log_time BOUNDFILLER,

    LOG_USER,

    log_Lab ' SUBSTR (: log_lab, 1, 4). "

    log_status,

    log_date_time ' TO_DATE (: log_date |: log_time, "MM/DD / YYYYHH24:MI:SS'"). "

    log_PC ' SUBSTR (: log_lab, 5) ')

    Scott@ORCL >-sql script which now enables to get the data and it concatenates the file name with the path of the directory

    Scott@ORCL >- and loads the data running SQL * Loader of SQL * Plus, using the HOST command:

    Scott@ORCL > test.sql TYPE of HOST

    COLUMN data_file new_value data_file

    SELECT 'c:\remote_location\login ' | TO_CHAR (SYSDATE, 'DD_MM_YY'). ".txt" AS data_file FROM DUAL

    /

    HOST SQLLDR scott/tiger CONTROL = test.ctl DATA = '& data_file' LOG = test.log

    CLEAR COLUMN

    Scott@ORCL >-table which includes the date and time in a column, for the day of the week can be extracted:

    Scott@ORCL > create table free_pc

    2 (log_in varchar2 (10))

    3, date log_date_time

    4, log_user varchar2 (30)

    5, log_Lab varchar2 (30)

    6, log_pc varchar2 (30)

    7, log_status char (1))

    8.

    Table created.

    Scott@ORCL >-load data file sql running running SQL * Loader using the control file:

    Scott@ORCL > test.sql START

    Scott@ORCL > data_file new_value data_file COLUMN

    Scott@ORCL > SELECT 'c:\remote_location\login ' | TO_CHAR (SYSDATE, 'DD_MM_YY'). ".txt" AS data_file FROM DUAL

    2.

    DATA_FILE

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

    c:\remote_location\login27_04_15.txt

    1 selected line.

    Scott@ORCL > HOST SQLLDR scott/tiger CONTROL = test.ctl DATA = '& data_file' LOG = test.log

    SQL * Loader: release 11.2.0.1.0 - Production on my Apr 27 12:00:53 2015

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

    Commit the point reached - the number of logical records 1

    Scott@ORCL > CLEAR COLUMN

    Scott@ORCL >-results with Date_Time field displayed in the form of day, date and time:

    Scott@ORCL > log_in COLUMN FORMAT A6

    Scott@ORCL > log_day COLUMN FORMAT A7

    Scott@ORCL > log_user COLUMN FORMAT A8

    Scott@ORCL > log_lab COLUMN FORMAT A8

    Scott@ORCL > log_pc COLUMN FORMAT A6

    Scott@ORCL > log_status FORMAT A10 COLUMN

    Scott@ORCL > SELECT log_in,.

    2 TO_CHAR (log_date_time, ' HH24:MI:SS Dy DD-Mon-YYYY ') ' DAY DATE TIME. "

    3 log_user, log_lab, log_pc, log_status

    4 FROM free_pc

    5.

    LOG_IN DAY DATE TIME LOG_USER LOG_LAB LOG_PC LOG_STATUS

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

    LogIN Mar 02 - Sep - 2014 ss18 N419 FS40 1 10:10:48

    1 selected line.

  • How to load xml using sql loader data?

    Is there any load script of XML data in a table through sql loader?

    Help me out here...

    Thank you

    You can post your code here? while I can help you... your code format should be like this...

    Example code:

    DOWNLOAD THE DATA

    INFILE *.

    IN THE TABLE po_tab

    ADD

    XMLTYPE (xmldata)

    FIELDS

    (xmldata TANK (2000))

    BEGINDATA

    "" http://www.Oracle.com/po/"xmlns: xsi ="http://www.w3.org/2001/XMLSchema-instance"

    "" xsi: schemaLocation = "http://www.oracle.com/PO http://www.oracle.com/scha0/po1.xsd"

    orderDate = "1999-10-20" >

    Alice Smith

    123 maple Street

    Mill Valley

    CA

    90952

    Robert Smith

    8 oak Avenue

    Old town

    PA

    95819

    Hurry, my lawn is going wild!

    Lawn mower

    1

    148.95

    Confirm this is electric

    Baby monitor

    1

    39.98

    1999-05-21

Maybe you are looking for