(8I) SQL*LOADER에서 | (PIPE LINE)을 RECORD SEPARATOR로 사용하기

제품 : ORACLE SERVER
작성날짜 : 2003-10-21
===============================================================
(8I) SQL*LOADER에서 | (PIPE LINE)을 RECORD SEPARATOR로 사용하기
===============================================================
PURPOSE
Oracle8i부터는 , SQL*Loader을 사용할때 record terminator을 지정할 수 있게
되었다.
Explanation
Oracle8i 이전에는 record seperator로 default로 linefeed(carriage return,
newline 등)였다. 이전에는 VAR 또는 FIX 등의 적당한 file을 다루기 위한 옵션을
주어야 하기 때문에 복잡한 감이 있었고 flexible하지 못했다.
Oracle8i부터는 , SQL*Loader을 사용할때 record terminator을 지정할 수 있게
되었다. newline 또는 carriage return 문자를 포함하는 data 또는 special 문자를
포함하는 data를 load하고자 할때 record terminator를 hexadecimal로 지정하여 활용할 수 있다.
Example
다음의 예제는 '|' (pipe line)을 record separator로 사용한다.
record separator를 사용하기 위해서 SQL*Loader의 control file에 'infile'절에 적당한 값을 지정하여야 한다.
아래의 예는 '|' (pipe line)을 사용하기 위해서
"str X'7c0a'"을 'infile'절에 지정하였다.
--controlfile : test.ctl
load data
infile 'test.dat' "str X'7c0a'"
into table test
fields terminated by ',' optionally enclosed by '"'
(col1, col2)
--datafile: test.dat
1,this is the first line of the first record
this is the second|
2,this is the first line of the second record
this is the second|
SQL> desc test
Name Null? Type
COL1 VARCHAR2(4)
COL2 VARCHAR2(100)
$ sqlldr scott/tiger control=test.ctl log=test.log
load된 data을 보면 아래와 같이 carriage return이 들어가 있는 data가 한 column에
제대로 들어간 것을 볼 수 있다.
SQL> select * from test;
COL1
COL2
1
this is the first line of the first record
this is the second
2
this is the first line of the second record
this is the second
RELATED DOCUMENT
<Note:74719.1>

Similar Messages

  • SQL* Loader - Multi-line record problem

    Hi all,
    I've been given a ver dirty source file. One that has records of more than 1 line. The only record terminator that is available is that the first columns should always be in number in 7 digits (0000000-9999999). Is it possible to create a control file that checks if the current record is actually a new record or if it is just a continuation of the previous record?
    I've been checking on some parameters like the CONTINUEIF and the "str terminator_string".
    I tried both but neither fully satisfies the requirements.
    I tried using CONTINUEIF by adding CONTINUEIF THIS (1) = '0' to check if it only creates records that has a column value starting with '0'. Unfortunately it still adds those that doesn't start with '0'.
    Also tried the INFILE 'mydata.dat' "str '\r\n0'". This works for those who starts with 0 only but unfortunately it trims out the first zero (0) from that column.
    Can someone suggest any other approach?
    Thanks.
    Allen

    hi,
    thanks for the suggestion. i did try it. it works ok but i also found a way to use sql loader since this is better performance wise. i used
    CONTINUEIF NEXT PRESERVE (8) <> X'09'.
    basically, what this does is check if the character on the 8th position is a tab. if it is, then it's a new line. i used this since the first column in my text file uses a 7 digit number. it's not perfect but loads fast. although i'm still looking for some other ways and means.
    thanks again.

  • SQL*Loader-510: Physical record in data file (clob_table.ldr) is long

    If I generate loader / Insert script from Raptor, it's not working for Clob columns.
    I am getting error:
    SQL*Loader-510: Physical record in data file (clob_table.ldr) is long
    er than the maximum(1048576)
    What's the solution?
    Regards,

    Hi,
    Has the file been somehow changed by copying it between windows and unix? Ora file transfer done as binary or ASCII? The most common cause of your problem. Is if the end of line carriage return characters have been changed so they are no longer /n/r could this have happened? Can you open the file in a good editor or do an od command in unix to see what is actually present?
    Regards,
    Harry
    http://dbaharrison.blogspot.co.uk/

  • How to refer the SQL*Loader command line parameters in the control file

    The problem I am trying to resolve is to insert the input file name when SQL*Loader is loading the record from the file. I have multiple files to load and it is nice to associate a record with a particular input file.

    Create the control file dynamically (and fill one of the columns with the file name as a constant) before you start SQL*Loader
    Another option is to use external tables
    Re: Data Loading
    Message was edited by:
    Jens Petersen

  • SQL*Loader command line call with spaces in path

    I need to call a remote control file and am attempting this:
    sqlldr USER/password@SERVER \\servername\drivename\Folder Name Messing Me Up\PLACE\Programs\QC2\Data\StandardRawFileRAW.ctlIt keeps telling me the file cannot be found, but it is there! How should I write this so it can find the file?
    Thank you so much!

    Wrap your path name in single quotes
    sqlldr USER/password@SERVER '\\servername\drivename\Folder Name Messing Me Up\PLACE\Programs\QC2\Data\StandardRawFileRAW.ctl'Regards,
    Phiri

  • SQL Loader - read 1st line to one table, rest of data to another

    Hi
    I looked around the FAQs and forums and find similar cases but not mine...
    I am running Oracle 9i and have a text file which has the 1st line as a control header and everything beneath it as data, something like this:
    14/07/2010|8
    12345678|0
    12345679|0
    12345680|10.87
    12345681|7655.8
    12345682|100
    12345683|0
    12345684|-90.44
    12345685|0
    The first (header) line has a date field and a counter (the number of records expected beneath it)
    The rest of the data is an account number and balance.
    Since SQL Loader is invoked outside of Oracle (Unix in my case) I assume I should create two tables, such as:
    Create table
    TIF_CURRENT_BALANCE_DTL
      ACCOUNT_REF_NO   VARCHAR2(30),  
      BALANCE_AMT      NUMBER(12,2)         
    Create table
    TIF_CURRENT_BALANCE_HDR
      HDR_DATE         DATE,  
      HDR_COUNT        NUMBER(10)
    );And use a control file which will load line 1 to TIF_CURRENT_BALANCE_HDR and other lines (SKIP=1) to TIF_CURRENT_BALANCE_DTL.
    Since the header/detail lines are not (necessarily) distinguishable, is there a way to achieve this, without modifying the input file in anyway?
    Thanks
    Martin

    Thanks for your reply - the solution should not be OS dependant as it will run on a Linux and UNIX installation.
    The DB will be (for now) Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
    I looked at that web page you provided and had some hope with the ROWS option, but this is the number of rows to load before each commit.
    Any other solutions?
    I know I could load it to a common table (text and number) and then convert the values accordingly in the PL/SQL procedure which will run afterwards, but I feel loading the data in the final format is going to be faster.
    I am considering using SQL Load to load records (SKIPping row 1) into the DTL table and within the PL.SQL loading the 1st record and performing validation. Since the file has approx 2million rows and is processed daily, 1.99999 million records read with SQL Loader and 1 with conventional methods will still be a vast improvement!
    Thanks

  • Sql loader - skip record question

    I am running Oracle 9 and using sql loader to import text file into table. Can sql loader skips the record which contain blank line or carriage return? Do I need to set up with options? Please advise me how. Thanks.

    http://docs.oracle.com/cd/B10500_01/server.920/a96652/ch05.htm
    http://www.orafaq.com/wiki/SQL*Loader_FAQ

  • Sql loader error

    I am using sql loader command line sqlldr to load 141306 records into my table. It ended with an error message --
    SQL*Loader-605: Non-data dependent ORACLE error occurred -- load discontinued.
    Checking for data load failures
    Checking Log data for clinic_biotox table data load
    90970 Rows successfully loaded.
    78 Rows not loaded due to data errors.
    And moreover (90970+78 = 91048) which is much less than 141306
    Any ideas as to what might have happened ?
    Thanks

    Have you checked the sqlldr log file (the name of which you should have supplied at the command line)? This sometimes provides additional information as to what occurred.
    I would also say that the reason why your record counts do not tally up like they should would be because the error occurred before sqlldr was able to complete the load.
    The last thing I can offer would be for you to check what your allowable error threshold is within your logfile. It could be that you exceeded the allowable number of bad records and as such caused the load to fail.
    Hope this helps...

  • Using a Table Trigger to Trap Error Codes Returned to a SQL Loader seeion

    I would be grateful if anyone knows how to go about this.
    I am trying to insert into a table, details of SQL Loader's rejected records by possibly using a trigger on the loading table to try and trap the error code returned to SQL Loader.
    What I am trying to achieve is to insert in to a table the load or rejected record details that are in SQL Loader’s log file after a load session. For example: records read:, records inserted:, records rejected:...etc..
    My main concern is that the loading table is regularly loaded, with 3m records, has 90 columns, and to check by referencing each column's new value, in the table trigger, may mean very long load times.
    Anyone got any “how to” ideas?
    Many thanks
    Regards
    Carlos

    Folks, thanks for your help.
    Previously, I had briefly considered both ideas and they would work.
    I dismissed the utl_file package solution because I believed that it would take too long to read in each log file line, search for the text and then inserts it into a table.
    I overlooked testing this and when I did (1mb file) it actually was pretty fast. I will go that route.
    Thanks for everyone’s help
    regards
    Carlos

  • Error in sql loader

    hi,
    when i am trying to load data using sql loader i come across the following errors and i was unable to load data into my staging tables.
    please explain me what are they and how to rectify them.
    SQL*Loader-524: partial record found at end of datafile (D:\oracle\prodappl\fnd\11.5.0\bin\sri3.ctl)
    Program exited with status 3
    SQL*Loader-500: Unable to open file (D:\oracle\prodappl\fnd\11.5.0\bin\sr2.ctl)
    OSD-04002: unable to open file
    O/S-Error: (OS 2) The system cannot find the file specified.
    please tell me where can i get complete information on errors occured during loading of data.
    please tell me whether there is any list of common errors encountered in sql*oader
    thanks in advance
    siddam
    Message was edited by:
    siddam
    null

    Both of datafile and control file should have line feed characters at the end.
    Check this site :
    http://radio.weblogs.com/0108008/stories/2003/04/11/experienceWithSqlLoader.html

  • SQL*Loader Error Field in data file exceeds maximum length", version 8.1.6

    Hi All,
    I am trying to load a data file into a database table using SQL loader. I
    received the data in an data file but I saved it as a pipe delimited
    file.
    When I run the SQL Loader command no records are loaded - looking at the log
    file I get the following error:
    Rejected - Error on table FARESDATA, column FANOTESIN.
    Then I tried with substr and doesnt seem to work for values greater than 4000 chars, it only works if the field value is below 4000 chars (say doing a substr for first 3000 chars).
    see the code--------
    LOAD DATA
    INFILE 'p.dat'
    APPEND INTO TABLE PROSPECTUS
    FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    Fanotesin char(4000) "substr(:fanotesin,1,4000)"
    We get the error ORA-01461: can bind a LONG value only for insert into a LONG column when using substr for 4000 chars.
    Please help!
    Thanks,
    Rajesh
    null

    I believe the problem here is that the ORACLE database regards anything > 4000chs as a CLOB (or LONG). 4000 is the maximum length of a varchar2 field in the database, although of course you can declare larger values in PL/SQL. (Since the incoming data is > 4000 chs it is regarded as a LONG and you cannot therefore use SUBSTR on it)
    I think that you must either truncate your data before loading or load into a table with the offending field as a CLOB (or LONG)
    and then use PL/SQL to recreate it in a table with a varchar2(4000) which is otherwise identical. (You can select from a LONG into a varchar2(32000) for example and then truncate before writing out to the new table).

  • Need help regarding sql loader

    Hi ,
    I am executing following command
    sqlldr admin_user@ces CONTROL=D:\sample_control.ctl log=D:\sample_log.log bad=D:\Sample_bad.bad
    In case of valid data it is inserting the data properly into the table. While invalid records added into the bad file.
    Now I want rollback valid data whenever count of bad file greater than equal to 10.
    In short whenever file has more than 10 invalid records , I don't want to insert any record from that file.
    Please provide me the solution.Thanks in advance.

    SQL*Loader Command-Line Reference
    DISCARDMAX(integer)
    Regards
    Etbin

  • Sql Loader -2

    Using SQL loader
    I have a requirment where i need to ucertain that each line contain only 5 occurances of "," (comma) in a CSV file ; is it possible using Sql loader ;
    example
    good record with five ,
    a,b,c,d,f,g
    bad record > 5 , or ,<5
    a,b,c
    a,b,c,d,e,f,g,h,
    Thanks in advance

    Does this count?
    External tables use SQL Loader functionality via the ORACLE_LOADER driver;
    You can create an external column with one large column;
    CREATE TABLE ext_tab
      col1  VARCHAR2(4000)
    ORGANIZATION EXTERNAL
      (  TYPE ORACLE_LOADER
         DEFAULT DIRECTORY dir1
         ACCESS PARAMETERS
           ( RECORDS DELIMITED BY NEWLINE
            FIELDS TERMINATED BY ','
            MISSING FIELD VALUES ARE NULL
         LOCATION (dir1:'sample_data.txt')
      );Then check to see which rows have more than five commas;
    select *
    from ext_tab
    where length(regexp_replace(col1, '[^,]')) > 5

  • Loading spatial data by sql *loader

    hi there
    i have a load_kat_opcina.ctl file from which i should load spatial data into my 10g db table.
    load_data.ctl file is as shown below:
    LOAD DATA
    INFILE *
    REPLACE
    CONTINUEIF NEXT(1:1) = '#'
    INTO TABLE KAT_OPCINA
    FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (KO_MBR          NULLIF KO_MBR=BLANKS,
    KO_SIFRA          NULLIF KO_SIFRA=BLANKS,
    KO_NAZIV          NULLIF KO_NAZIV=BLANKS,
    KO_ID          NULLIF KO_ID=BLANKS,
    ID          NULLIF ID=BLANKS,
    is_null1 FILLER CHAR,
    POVRSINA     COLUMN OBJECT NULLIF is_null1='E'
    (     sdo_gtype INTEGER EXTERNAL,
         sdo_srid INTEGER EXTERNAL NULLIF POVRSINA.sdo_srid=BLANKS,
         SDO_POINT COLUMN OBJECT NULLIF is_null1='C'
              ( X INTEGER EXTERNAL,
              Y INTEGER EXTERNAL,
              Z INTEGER EXTERNAL NULLIF POVRSINA.SDO_POINT.Z=BLANKS),
         SDO_ELEM_INFO VARRAY terminated by ';' NULLIF is_null1='P'
         (SDO_ORDINATES INTEGER EXTERNAL),
         SDO_ORDINATES VARRAY terminated by ':' NULLIF is_null1='P'
         (SDO_ORDINATES INTEGER EXTERNAL)
    BEGINDATA
    0|426|MARKU[EVEC|314717|6789094|
    0|3131|VURNOVEC|16605787|6789097|
    #C|2003|||||1|1005|3|1|2|1|169|......|5589490440|5082192250:
    0|3034|\UR\EKOVEC|16225011|6789100|
    0|35|^EHI|12297784|6789190|
    #C|2003|||||1|1005|2|1|2|1|239|....|5574944600|5064714553:
    0|221|ODRANSKI OBRE@|12441649|6789193|
    0|353|TRPUCI|14071974|6789199|
    i have deleted most of data here due to space savings.
    i call sql *loader from winxp command prompt as follows:
    SQLLDR CONTROL=C:\temp\load_kat_opcina.ctl, USERID=username/pswrd@sid, LOG=logfile.log,BAD==baz.bad, DISCARD=DISCARD=toss.dsc
    after executing command, table 'kat_opcina' is not filled with data from this .ctl file.
    the following is the content of the log file:
    SQL*Loader: Release 10.2.0.1.0 - Production on Sri Svi 31 14:20:28 2006
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Control File: C:\TEMP\load_kat_opcina.ctl
    Data File: C:\TEMP\load_kat_opcina.ctl
    Bad File: C:\TEMP\baz.bad
    Discard File: C:\TEMP\toss.dsc
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array: 64 rows, maximum of 256000 bytes
    Continuation: 1:1 = 0X23(character '#'), in next physical record
    Path used: Conventional
    Table KAT_OPCINA, loaded from every logical record.
    Insert option in effect for this table: REPLACE
    TRAILING NULLCOLS option in effect
    Column Name Position Len Term Encl Datatype
    KO_MBR FIRST * | O(") CHARACTER
    NULL if KO_MBR = BLANKS
    KO_SIFRA NEXT * | O(") CHARACTER
    NULL if KO_SIFRA = BLANKS
    KO_NAZIV NEXT * | O(") CHARACTER
    NULL if KO_NAZIV = BLANKS
    KO_ID NEXT * | O(") CHARACTER
    NULL if KO_ID = BLANKS
    ID NEXT * | O(") CHARACTER
    NULL if ID = BLANKS
    IS_NULL1 NEXT * | O(") CHARACTER
    (FILLER FIELD)
    POVRSINA DERIVED * COLUMN OBJECT
    NULL if IS_NULL1 = 0X45(character 'E')
    *** Fields in POVRSINA
    SDO_GTYPE NEXT * | O(") CHARACTER
    SDO_SRID NEXT * | O(") CHARACTER
    NULL if POVRSINA.SDO_SRID = BLANKS
    SDO_POINT DERIVED * COLUMN OBJECT
    NULL if IS_NULL1 = 0X43(character 'C')
    *** Fields in POVRSINA.SDO_POINT
    X NEXT * | O(") CHARACTER
    Y NEXT * | O(") CHARACTER
    Z NEXT * | O(") CHARACTER
    NULL if POVRSINA.SDO_POINT.Z = BLANKS
    *** End of fields in POVRSINA.SDO_POINT
    SDO_ELEM_INFO DERIVED * ; VARRAY
    NULL if IS_NULL1 = 0X50(character 'P')
    *** Fields in POVRSINA.SDO_ELEM_INFO
    SDO_ORDINATES FIRST * | O(") CHARACTER
    *** End of fields in POVRSINA.SDO_ELEM_INFO
    SDO_ORDINATES DERIVED * : VARRAY
    NULL if IS_NULL1 = 0X50(character 'P')
    *** Fields in POVRSINA.SDO_ORDINATES
    SDO_ORDINATES FIRST * | O(") CHARACTER
    *** End of fields in POVRSINA.SDO_ORDINATES
    *** End of fields in POVRSINA
    Record 1: Rejected - Error on table KAT_OPCINA.
    ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
    ORA-13365: layer SRID does not match geometry SRID
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 623
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 227
    Record 2: Rejected - Error on table KAT_OPCINA.
    ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
    ORA-13365: layer SRID does not match geometry SRID
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 623
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 227
    Record 33: Rejected - Error on table KAT_OPCINA.
    ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
    ORA-13365: layer SRID does not match geometry SRID
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 623
    ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 227
    SQL*Loader-510: Physical record in data file (C:\TEMP\load_kat_opcina.ctl) is longer than the maximum(65536)
    SQL*Loader-2026: the load was aborted because SQL Loader cannot continue.
    Specify SKIP=33 when continuing the load.
    Table KAT_OPCINA:
    0 Rows successfully loaded.
    33 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: 215168 bytes(64 rows)
    Read buffer bytes: 1048576
    Total logical records skipped: 0
    Total logical records read: 33
    Total logical records rejected: 33
    Total logical records discarded: 0
    Run began on Sri Svi 31 14:20:28 2006
    Run ended on Sri Svi 31 14:20:32 2006
    Elapsed time was: 00:00:04.51
    CPU time was: 00:00:00.26
    error messages are all the same for record numbers: 3-32.
    so, i'd like to know what am i doing wrong that table cannot be filled with data using sql *loader.
    also, would like to know if there's another way of loading data into table from .ctl file (using maybe some other tool)
    appreciate any help
    thanks

    Hi,
    You receive:
    ORA-29875: failed in the execution of the ODCIINDEXINSERT routine
    ORA-13365: layer SRID does not match geometry SRID
    Have you created spatial index for table PORVSINA? I guess that yes, and you have created it with non NULL SRID value? So, ORA-13365 means that you are trying to insert spatial data with SRID that is not the same as SRID defined in spatial index.
    Check index SRID and your data SRID, they must be the same. Or, you can disable spatial index.
    Andrejus

  • Oracle8i Std Ed SQL*Loader Error

    Please re-direct if another forum is more appropriate for this question:
    Continually receive "SQL*Loader-524: partial record found at end of datafile (d:\development\database\cust_info_load.ctl)" error when trying to load data into a table from a character-delimited flat-file.
    I've already read the online doc. I've already looked up the SQL*Loader-524 error message without yielding useful information.
    I am following the exact syntax for both the *.dat file and the *.ctl file as listed in several Oracle text. The *.dat file has only one line and no matter what I try... it won't load (permissions are not the issue).
    I found a web site stating in 8.0.5 you have to enter a linefeed command at the end of each line in order for SQL*Loader to work properly. Thought I'd try it in 8.1.5 (why not). In NT, how do I do this? /n doesn't work; hitting the [enter] key doesn't work.
    I have to get this working. Please e-mail me if you have ideas but need further info about either the *.dat or *.ctl files.
    TIA! [email protected]

    Please send your .ctl, .dat file and the table structure to which you are uploading.
    Since I am working with SQL LOADER, I may find a solution.
    Thanks

Maybe you are looking for

  • Qosimio G30-116 with blue screen on boot

    I have a Qosmio dule boot Qosmio G30-116, booting in windows generates a blue screen of death, which is quickly cleared before I can read what is displayed. Boot it in windows safe mode results in a long list of files being displayed the last one bei

  • HP ENVY 700-210xt CTO Desktop PC/windows 8.1: can't display 2nd monitor

    Detail information: -  HP ENVY 700-210XT CTO Desctop PC -  One VGA port and one DVI-D port (used DVI-D to DVI-D cable to connect to second monitor) -  video card is a buildin card on motherboard -  Two monitors: AOC 10X16, Acer 12X15 (with both VGA a

  • Migration of Oracle 7.3.4.2 to Oracle 8i or Oracle 9i

    i need a clarification in regard with the migration of Oracle 7.3.4.2 to Oracle 8i or 9i along with the porting of the underlying OS from win NT to Win 2000. can u please eloborate me on the issues which i need to look into (if any).and cud u pls elo

  • Concurenncy - synchronization problems

    Hello, I have read about synchronization in about 5 sources so far and I still don't understand it and mostly because of codes that sources show do not work as they are intended to work. For example I will show the code from this webpage: http://www.

  • I always get a retry download error

    I have an ipad air. ever since I upgraded to IOS 8 I always get a retry download error. What's going on with this one?