SQL Loader, CLOB, delimited fields

Hello.
I have to load using SQL Loader data from csv file into table, which one field is CLOB type.
Here is how ctl file initially looked like:
UNRECOVERABLE
LOAD DATA
INFILE '.\csv_files\TSH_DGRA.csv'
BADFILE '.\bad_files\TSH_DGRA.bad'
DISCARDFILE '.\dsc_files\TSH_DGRA.dsc'
APPEND
INTO TABLE TSH_DGRA
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
ID_OBJ_TSHD,
PR_ZOOM_TSHD,
PR_GRID_TSHD,
PR_ELMGR_TSHD CHAR(4000) OPTIONALLY ENCLOSED BY '<clob>' AND '</clob>',
PR_ALRMGR_TSHD CHAR(4000) OPTIONALLY ENCLOSED BY '<clob>' AND '</clob>'
Problems are fields PR_ELMGR_TSHD and PR_ALRMGR_TSHD (CLOBs in table TSH_DGRA). Until data which should be loaded into CLOB fields are under 4000 characters long, it works fine, but what should I do if I want to load data which are longer than 4000 characters?
If found on Link:[http://download.oracle.com/docs/cd/B14117_01/server.101/b10825/ldr_loading.htm#i1006803] which one sentence said that:
"SQL*Loader defaults to 255 bytes when moving CLOB data, but a value of up to 2 gigabytes can be specified. For a delimited field, if a length is specified, that length is used as a maximum. If no maximum is specified, it defaults to 255 bytes. For a CHAR field that is delimited and is also greater than 255 bytes, you must specify a maximum length. See CHAR for more information about the CHAR datatype."
So, my question is, how to specify "up to 2gb" as text said? I can not use CHAR datatype because it is limited to 4000 characters. And I have to load about 60000 characters. I also can not use technique where all data for every CLOB field are in separate files.

Just specify the maximum expected size:
PR_ELMGR_TSHD CHAR(100000) OPTIONALLY ENCLOSED BY '<clob>' AND '</clob>',
PR_ALRMGR_TSHD CHAR(1000000) OPTIONALLY ENCLOSED BY '<clob>' AND '</clob>'
The CHAR(1000000) will allow SQLLDR to handle up to 1000000 bytes of input text.

Similar Messages

  • SQL Loader CLOBs

    I am moving data from an oracle 10g table to another oracle 10g table, transforming the data in Access, filtering records, merging fields, etc.., then via Access VBA creating CTL files and neccessary scripts, then loading the data via SQL Loader. Getting the CLOBs to load is not a problem, getting it to load with the formatting is. The records in the control file look fine, the formatting is kept just fine in the CTL file, but when it is loaded all the carriage returns, line feeds, etc are removed
    Here is the header of my CTL file:
    LOAD DATA
    INFILE *
    CONTINUEIF LAST != "|"
    INTO TABLE table_name
    APPEND
    FIELDS TERMINATED BY '||' TRAILING NULLCOLS
    (field1, field2, field3....etc)
    begindata
    field1||field2||field3||fieldx|
    At first i thought taking out the TRAILING NULLCOLS would help but i get the same result.
    The end result i am looking for is keeping the data formatted exactly as it is in the source table.
    Thanks
    Mike

    After doing some research it seems that the only way is creating a file with the clob, see http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_loading.htm#i1007627
    Control File Contents:LOAD DATA
    INFILE 'sample.dat'
    INTO TABLE person_table
    FIELDS TERMINATED BY ','
    (name CHAR(20),
    ext_fname FILLER CHAR(40),
    "RESUME" LOBFILE(ext_fname) TERMINATED BY EOF)
    Datafile (sample.dat):
    Johny Quest,jqresume.txt,
    Speed Racer,'/private/sracer/srresume.txt',
    Secondary Datafile (jqresume.txt):
    Johny Quest,479 Johny Quest
    500 Oracle Parkway
    [email protected]>
    HTH
    Enrique

  • Sql loader - record delimiter

    Hi
    I am using sql loader to load data in a table, the field terminator is '|' , there are multi line datas for one field, i want to specify the record delimiter.
    it considers new line as one record.
    how to specify the record delimiter
    Thanks in advance
    S Sathish Kumar

    LOAD DATA
    INFILE 'C:\FLATFILE\MAPPING.DAT'
    DISCARDFILE 'C:\FLATFILE\MAPPING.DSC'
    APPEND INTO TABLE ETL_MAPPING_METADATA
    RECORDS DELIMITED BY '#^'
    FIELDS TERMINATED BY '|'
    Hi i have tried the above code, but it is not working, also i replaced 'records delimited' by 'records terminated'

  • SQL Loader - Set a field to a CONSTANT and the data is date

    Hi.
    I have a question on SQL Loader.
    I want to load a field(field name is TIME_IN).
    In the Oracle table, this field type is DATE.
    I my csv file, I do not put any value for this field.
    I intend to use CONSTANT variable to this field.
    In my control file, following is the command for above field.
    Hoever, when I run the SQLLoader, it will return me error message which is INVALID MONTH.
    I hope somebody can help and advise me on this matter.
    Thanks.
    INTO TABLE eqreceival_temp
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'     
    EQ_NO,
    SIZE_TYPE,
    CUSTOMER,
    CONSTRUCTION,
    QUALITY,
    CONDITION,
    DATE_IN DATE "DD/MM/YYYY",
    TIME_IN CONSTANT '01/01/1999',
    PARK_LOC CONSTANT 'CP',
    STOCK CONSTANT 'S',
    DISCHARGE_PORT CONSTANT 'MYPEN',
    CTYPE CONSTANT 'P',
    ROAD CONSTANT 'Y',
    GATE CONSTANT 'Y',
    SHIPMENT CONSTANT 'Y'
    )

    use to_data function when u r inserting....
    or
    give simply SYSDATE --- AND FIRST CHECK
    --YOU MAY REMOVE CONSTANT KEY WORD.                                                                                                                                                                                                                                                           

  • Sql*loader and sdo_geometry field

    Is there a way to load longitude/latitude coordinates from a flat file directly into an sdo_geometry field with sql*loader? If so, does anyone have an example? I just want to create point features.
    Thanks,
    David

    David,
    Section 4.1.2 of the Spatial User Guide has examples for this:
    LOAD DATA
    INFILE *
    TRUNCATE
    CONTINUEIF NEXT(1:1) = '#'
    INTO TABLE POINT
    FIELDS TERMINATED BY '|'
    TRAILING NULLCOLS (
    GID INTEGER EXTERNAL,
    GEOMETRY COLUMN OBJECT
    SDO_GTYPE INTEGER EXTERNAL,
    SDO_POINT COLUMN OBJECT
    (X FLOAT EXTERNAL,
    Y FLOAT EXTERNAL)
    BEGINDATA
    1| 2001| -122.4215| 37.7862|
    2| 2001| -122.4019| 37.8052|
    3| 2001| -122.426| 37.803|
    4| 2001| -122.4171| 37.8034|
    5| 2001| -122.416151| 37.8027228|
    You need to add the SRID field if you want to add the SRID to the geometry.
    Or you can do that with SQL after the data is loaded into the DB.
    siva

  • SQL Loader error on Fields terminated and optionally enclosed

    When you have fields terminated and optionally enclosed, you should be able to have the enclosure characters within the data by doubling them.
    So if I have fields terminated by '|' optionally enclosed by '"' and my data has a double quote in it, I can get SQL Loader to take it by replacing the double quote with two double quotes.
    But this doesn't always work. For some reason the following string gets the error "no terminator found after TERMINATED and ENCLOSED field"
    |"TRO2 ldj?=)(/&%ç*""aàéè_:;!àèé,jpdjbdbd"|
    Apparently having the double quote immediately after an asterisk makes SQL Loader not see the second double quote. If I edit it and remove the two double quotes it loads OK. Also if I change the string to
    |"TRO2 ldj?=)(/&%ç*aà""éè_:;!àèé,jpdjbdbd"|
    Moving the double quote away from the asterisk it loads OK.
    Anybody encounter this problem before?

    Oracle version is 11.1.0.7.0
    OS is Windows 6.1.7601
    I can't remove the "optionally enclosed by" clause because we're getting the data from another system. Fortunately this is test data and this particular combination of characters is unlikely to occur in production data.

  • SQL Loader: ignore data field

    Hi,
    in a SQL Loader control file, how do you specify that you do not wish to load a particular field?
    E.g. if I wanted to ignore the second field in the data file and load the first and third fields into a table, how would I modify the control file below?
    Thanks.
    load data
    infile 'example.dat'
    into table example
    fields terminated by ',' optionally enclosed by '"'
    col1 char,
    ignore char,
    col2 char
    )

    User FILLER keyword:
    col1 char,
    ignore filler char,
    col2 char
    )

  • SQL Loader + CLOB

    Dear buddies,
    Please guide me with this.
    LOAD DATA
    INFILE 'D:\load\dat\Enquiry_reply.dat'
    BADFILE 'D:\load\bad\Enquiry_reply.bad'
    DISCARDFILE 'D:\load\dat\discard\Enquiry_reply.dsc'
    replace INTO TABLE OES_Enquiry FIELDS TERMINATED BY '['
    *(Reply CLOBFILE("D:\load\dat\oes_enquiry_reply.dat") TERMINATED BY '[')*
    Whats wrong here in this?
    I am getting error:
    SQLLoader-350: Syntax error at line 6.*
    Expecting "," or ")", found "CLOBFILE".
    *(Reply CLOBFILE("D:\load\dat\enquiry_reply.dat") TERMINATED BY '['*
    Please advice me on how to go about it.
    Thanks in advance.
    Nith

    This forum is meant for issues with database upgrades - pl re-post in the SQL*Loader forum (Export/Import/SQL Loader & External Tables
    HTH
    Srini

  • Sql Loader record delimiter (SPECIAL CASE)

    I have a special case where I want to use <EOR>\n as record delimiter, but OWB won't load any data with that. If I only use <EOR> it does load data but throws warning (1 Row not loaded because all fields were null), TRAILING NULLCOLS option is enabled. I appreciate the help.

    Hi David,
    First of all, I appreciate your reply. I did do what you recommended (OMBALTER FLAT_FILE 'ABCD' SET PROPERTIES (RECORD_DELIMITER) VALUES ('<EOR>\n'). I didn't open the FF, but I did sync the FF and deployed the mapping unfortunately it didn't work "File processing option string: "STR X'3C454F523E5C6E'" (basically HEX values)
    Any more suggestions?
    The reason I want to use this record delimiter is:
    LINE1 = AB|CD|EF|GH|IJKL<EOR>$ note:($ is \n)(set list)
    LINE2 = AB|CD|EF|GH|IJKL$
    MNOPQRSTUVWX$
    YZ<EOR>$
    For the time being I fixed the problem by putting all columns(ROW EACH) in a single row and just use '\n' as RD, but I would like to do it by using ('<EOR>\n') as RD as well.
    I appreciate the help.

  • SQL loader for empty field at the end of the line

    Hi,
    I have following data file for sql loader. I am using Oracle 11.2. The table structure is table_a(id number, name varchar2(32), nbr number).
    1, zzzz, 123
    2, bbb,
    3, ccc, 33
    4, ddd,
    Currently, I am using "TERMINATED BY ',' " in the control file for SQL loader. However row2 and row4 were thrown into the bad file. Any suggestion for me to load row2 and row4 into the table as well?
    Thanks,

    Two of three columns in your table are named with reserved words.
    My first suggestion is to run this query:
    SELECT keyword
    FROM v$reserved_words
    ORDER BY 1;My second suggestion is that your read the FAQ and learn how to use tags to post listings to these forums so we can read what you post.
    My third suggestion is that you go to my SQL*Loader Demos page of my website:
    http://www.morganslibrary.org/reference/sqlloader.html
    and look up "TRAILING NULLCOLS."                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Using sql load insert multiple fields data into a single column in database

    Hi ,
    I have my log file in sun OS box something like this
    =======
    (07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011
    (07/29/2009 00:02:26.236) 3675 (07/29/2009 00:02:28.207) 949395117
    (07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864
    =============
    I am trying to insert the data into oracle data base as follows.
    =============================
    column1 : (07/29/2009 00:02:24.467)
    column2 : 367518
    column3 : (07/29/2009 00:02:26.214)
    column4 : 949384011
    ===========================
    Can anyone help me with the control file format?
    someone suggested me the code below.
    ==========
    LOAD DATA
    INFILE 'D:\work\load.txt'
    INTO TABLE sample
    (col1 POSITION(02:24) char,
    col2 POSITION(27:32) INTEGER EXTERNAL,
    col3 POSITION(35:57) CHAR,
    col4 POSITION(60:68) INTEGER EXTERNAL
    ===========
    but this works only for the fixed length data? Please help

    user11744904 wrote:
    Hi ,
    I have my log file in sun OS box something like this
    =======
    (07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011
    (07/29/2009 00:02:26.236) 3675 (07/29/2009 00:02:28.207) 949395117
    (07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864
    =============
    I am trying to insert the data into oracle data base as follows.
    =============================
    column1 : (07/29/2009 00:02:24.467)
    column2 : 367518
    column3 : (07/29/2009 00:02:26.214)
    column4 : 949384011
    ===========================
    Can anyone help me with the control file format?
    someone suggested me the code below.
    ==========
    LOAD DATA
    INFILE 'D:\work\load.txt'
    INTO TABLE sample
    (col1 POSITION(02:24) char,
    col2 POSITION(27:32) INTEGER EXTERNAL,
    col3 POSITION(35:57) CHAR,
    col4 POSITION(60:68) INTEGER EXTERNAL
    ===========
    but this works only for the fixed length data? Please helpIs the requirement to load all data in a single column or multiple columns? The thread subject and body are conflicting.

  • SQL Loader fails loading XML data enclosed by tag not found

    The problem I'm having is my XML tree doesn't contain all possible elements. In this example the second entry doesn't contain <age> - only the first entry will be added to the database
    Any idea of how I could solve this?
    The fields are saved as varchar2
    XML:
    <rowset>
    <row>
    <name>Name</name>
    <age>Age</age>
    <city>City</city>
    </row>
    <row>
    <name>Name2</name>
    <city>City2</city>
    </row>
    </rowset>
    LOAD DATA
    INFILE 'data.xml' "str '</row>'"
    APPEND
    INTO TABLE test
    TRAILING NULLCOLS
    dummy FILLER terminated BY "<row>",
    name ENCLOSED BY "<name>" AND "</name>",
    age ENCLOSED BY "<age>" AND "</age>",
    city ENCLOSED BY "<city>" AND "</city>"
    )

    I noticed that failure occurs when using 11g version SQL Loader. It doesn't fail when using 10g version SQL Loader.
    Delimited source data comes from:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - ProductionAnd will be loaded into
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    CORE    10.2.0.5.0      Production
    TNS for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - ProductionMy previously used SQL Loader was from:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - ProductionIt seems that I have found the real culprit. Should I know something more?

  • SQL Loader - Junk characters

    Hi ALl
    This may not be exactly a SQL Loader problem.
    I have a XCEL file which I convert to Tab delimited file
    before using SQL Loader to load the records.
    But the XCEL file has some junk characters. So when I save it as tab delimited format the junk character is replaced by a new line. So SQL Loader treats it as next record and it fails
    If I save it as comma delimited, I face another problem. There is a description field which has commas in it.
    For eg. "XYZ Corporation, Phoenix"
    So SQL Loader treats "Phoenix" as a next field. Again it fails.
    Please can you help me on this.
    Thanks
    Ashwin N.

    I entered the phrase 'XYZ Corporation, Phoenix' in a cell (in Microsoft Excel 2002) and used the command 'Save as' from the menu 'File' to save the file as of type 'csv'.
    When I opened the file in notepad I could see the enclosed double quotes. You could save the file the same way.
    After that, use the method suggested by Al Glick in your Sql*Loader control file.
    fields terminated by ","
    optionally enclosed by '"'

  • ADVANCED SQL*LOADER

    제품 : ORACLE SERVER
    작성날짜 : 2002-04-25
    Advanced SQL*LOADER
    ====================
    PURPOSE
    Q&A를 통한 SQL*LOADER 사용 방법에 대해 알아보도록 한다.
    Explanation
    1) Carriage returns, linefeeds, EOL character를 load 하는 방법
    2) Delimiter 를 사용한 경우 특정 field 를 skip 할수 있나?
    3) "FIELD IN DATA FILE EXCEEDED MAXIMUM SPECIFIED LENGTH" 메세지
    해결 방법
    4) Blob 이나 raw data 는 어떻게 사용하나?
    5) Error LDR-510은 어떻게 처리하나?
    6) EBCDIC Characterset data file 은 어떻게 load 하나?
    7) Control file 에 WE8EBCDIC500 characterset 을 사용하였는데도
    SQL*Loader-266 가 발생하는 경우
    8) Decimal data는 어떻게 load 하는가?
    9) Trailing signs 이 있는 숫자는 어떻게 load 하는가?
    10) Zoned number는 무엇인가?
    11) Packed Decimal Number는 무엇인가?
    12) NULLIF 는 어떻게 사용하나 ?
    13) 한개의 single column을 위해 여러 개의 nullif는 사용가능한가?
    14) SQL*Loader 가 NULL 로 여기는 column 을 blank space 로
    여기도록 만들려면 ?
    15) WHEN 절은 어떻게 사용하나?
    16) WHEN 절에 OR 를 사용할수 있는가?
    17) Delimiter 로 ','를 사용하였는데 data 에 ','가 포함된 경우는?
    18) 어떻게 하면 commit 을 덜 사용할 수 있나?
    1) carriage returns, linefeeds, EOL character를 load 하기
    SQL*Loader 는 이들을 통해 서로 다른 physical record 로 인식한다.
    이들을 load 하기 위해 사용되는 option 은
    - concatenate
    - continueif
    - file processing option: FIX (PRE: 1012555.6 PRS: 2060647.6)
    - file processing option: VAR (PRE: 1011372.6 PRS: 2059405.6)
    예제1) concatenate 사용하기
    Control File: test.ctl
    load data
    infile 'test.dat'
    truncate
    concatenate (2)
    into table test
    (col1 char(2000))
    Data File: 'test.dat'
    This is a test \n
    this is the second Line.
    This is a new record\n
    this is the second line of the second record
    결과:
    SQL> select * from test;
    COL1
    This is a test \nthis is the second Line.
    This is a new record\nthis is the second line of the second record
    예제2) continueif 를 사용하기
    Control File: test.ctl
    load data
    infile test.dat
    truncate
    continueif this (1) = '*'
    into table test
    (col1 char(64000))
    Data File: 'test.dat'
    *11111111111
    *22222222222
    *33333333333
    *44444444444
    *55555555555
    66666666666
    *77777777777
    *88888888888
    999999999999
    *aaaaaaaaaaa
    *bbbbbbbbbbb
    cccccccccccc
    *ddddddddddd
    *eeeeeeeeeee
    *fffffffffff
    *ggggggggggg
    *hhhhhhhhhhh
    결과 :
    SQL> select * from test;
    COL1
    11111111111222222222223333333333344444444444555555555556666666666
    777777777778888888888899999999999
    aaaaaaaaaaabbbbbbbbbbbccccccccccc
    dddddddddddeeeeeeeeeeefffffffffffggggggggggghhhhhhhhhhh
    2) delimiter 를 사용한 경우 특정 field 를 skip 할수 있나 ?
    : 불가능하다 (RTSS Bulletin: 103235.426)
    3): 모든 column 에 해당 column 에 해당하는 length 를 지정하였는데
    다음과 같은 error message 를 접한 경우 :
    "FIELD IN DATA FILE EXCEEDED MAXIMUM SPECIFIED LENGTH"
    :255 자 이상의 char/varchar2/long field 를 load 하려한 경우
    이 경우는 CHAR data type 의 buffer size 를 증가 시켜야 한다.
    이의 default 는 255 이다.
    예제)
    load data
    into table
    (col1 char(64000))
    이 경우 buffer 를 64K 로 증가시켜 col1 에 load 해야 한다.
    <주의> 64K 는 sql*loader 에서 사용 가능한 maximum record length이다.
    이는 1 record 를 여러개의 buffer 를 통해 load 하지 못하는 문제이다.
    최대 buffer 는 64k 이다.
    64 K 이상을 원하는 경우
    a) 여러개의 작은 chunk 로 나누거나,
    b) SQL*Loader 를 사용하지 못한다.
    4) blob 이나 raw data 는 어떻게 사용하나 ?
    : RAW datatype 을 사용하고 length를 부여한다.
    예제)
    LOAD DATA
    INFILE xx.dat "VAR"
    REPLACE
    INtO TABLE test
    (BLOB raw (32767) )
    xx.dat 는 load 하고자 하는 전체 file 이다.
    이는 bit mapped files 이나, 그외 file type 을 DB 에 load 시
    사용 가능한 option 이다.
    5) error LDR-510은 어떻게 처리한가 ?
    : LDR-510은 data file 안의 physical record가 최대값인 64K 를
    넘은 경우이다.
    SQL*Loader 에서는 physical record 가 연속적이어야 하며, 이는
    최대인 64k 를 넘지 못하는 제한이 있기 때문이다.
    (여러 buffers 를 통해 load 불가능)
    이는 위의 1번과 같으므로 physical record 를 여러 logical record 로
    나누어야 한다.
    6) EBCDIC Characterset data file 은 어떻게 load 하나 ?
    : control file 에 characterset 을 명시한다.
    많이 사용되는 EBCDIC character set 은 WE8EBCDIC500 이다.
    예제)
    load data
    characterset we8ebcdic500
    infile *
    replace
    into table for_load
    (x)
    begindata
    B
    Z
    X
    SQL> select * from for_load;
    X
    a
    i
    이는 ASCII 의 경우도 같다.
    7) control file 에 WE8EBCDIC500 characterset 을 사용하였는데도
    SQL*Loader-266 가 발생하는 경우
    환경변수인 ORA_NLS 가 맞게 설정되었는지를 check 한다.
    (PRE: 1012552.6 PRS: 2060644.6)
    8) decimal data 는 어떻게 load 하는가?
    : data 를 조작하는 방법밖에 없다.즉 decimal point 가 들어가게
    data 를 조작한다.
    예제)
    load data
    infile *
    truncate
    into table test
    (col1 integer external(5) ":col1/100")
    begindata
    12345
    10000
    24983
    SQL> select * from test;
    COL1
    123.45
    100
    249.83
    9) trailing signs 이 있는 숫자는 어떻게 load 하는가?
    예제)
    load data
    infile *
    truncate
    into table loadnums
    (col1 position(1:5),
    col2 position(7:16) "to_number(:col2,'99,999.99MI')")
    begindata
    abcde 1,234.99-
    abcde 11,234.34+
    abcde 45.23
    abcde 99,234.38-
    abcde 23,234.23+
    abcde 98,234.23+
    SQL> select * from loadnums;
    COL1 COL2
    abcde -1234.99
    abcde 11234.34
    abcde -99234.38
    abcde 23234.23
    abcde 98234.23
    <주의> 이경우 log file 에 다음의 error message 를 볼수있다.
    Record 3: Rejected - Error on table LOADNUMS, column COL2.
    ORA-01722: invalid number
    이 error message 는 당연한 것이다.
    왜냐면 control file 에 number datatype 에 mask 를 주었기 때문에
    모든 number 는 mask 를 가져야 한다.
    이때 Record 3은 trailing sign 이 없기 때문에 reject 된 것이다.
    10) zoned number는 무엇인가?
    이는 decimal digit 의 string 으로 1byte 에 1 string 이 해당된며,
    부호가 맨 마지막byte 에 포함되는 경우이다.
    예제)
    LOAD DATA
    infile *
    append
    INTO TABLE test
    (col1 position(1:3) zoned(3),
    col2 position(4:6),
    col3 position(7:8))
    begindata
    12J43323
    43023423
    SQL> select * from test;
    COL1 COL2 COL3
    -121 433 23
    430 234 23
    2 rows selected.
    다음은 zoned values의 map 이다:
    {ABCDEFGHI}JKLMNOPQR0123456789
    ++++++++++----------++++++++++
    {ABCDEFGHI}JKLMNOPQR
    01234567890123456789
    11) Packed Decimal Number는 무엇인가 ?
    : packed decimal format은 bytes 로 이루어진 1 string 의 모음인데
    각각은 2 digit (2 nibbles) 을 가진다.
    이중 마지막 byte 는 1 digit 와 sign 으로 이루어진다.
    이 sign 은 보통 0x0a, 0x0b, ..., 0x0f: usually 0x0c/a/e/f for +ve,
    0x0d/b for -ve 로 이루어져 있다.
    예를 들어 +123 의 packed decimal 표현은 다음과 같다.
    [12] [3C] 이고 이때 [12] 는 nibbles 0x01 and 0x02를 포함하는
    byte 이다. [3C]의 경우도 같다.
    The kernel 은 sing nibble 의 여부를 ttcp2n() 을 통해 check한다.
    만일 0x0a, ..., 0x0f 중의 하나가 아니면 ORA-1488 error 를 발생시킨다.
    <주의> BUG:296890:
    이는 bug 는 아니며, SQL*Loader 는 COBOL 에서 발생시키는 UNSIGNED
    packed decimal 을 support 하지 않는다.
    즉 SQL*Loader 는 packed decimal을 load 시 마지막 byte 가 반드시
    1 digit와 ,sign 이 포함되어지는지 check 한다.
    12) NULLIF 는 어떻게 사용하나 ?
    예제)
    load data
    infile *
    truncate
    into table test
    fields terminated by ','
    (col1 date "mm/dd/yy" nullif col1='0', col2)
    begindata
    0,12345
    11/11/95,12345
    0,12345
    11/11/95,12345
    SQL> select * from test;
    COL1 COL2
    12345
    11-NOV-95 12345
    12345
    11-NOV-95 12345
    13) 한개의 single column을 위해 여러 개의 nullif 는 사용가능한가 ?
    : 불가능하다. 그러나 workaround 로는
    예제)
    load data
    infile *
    truncate
    into table test
    fields terminated by ',' optionally enclosed by '"'
    (col1,col2 "decode(:col2,'X',NULL,'Y',NULL,'Z',NULL,:col2)",col3)
    begindata
    12345,"X",12345
    12345,"A",12345
    12345,"Y",12345
    12345,"Z",12345
    12345,"B",12345
    SQLDBA> select * from test;
    COL1 COL2 COL3
    12345 12345
    12345 A 12345
    12345 12345
    12345 12345
    12345 B 12345
    5 rows selected.
    14) SQL*Loader 가 NULL 로 여기는 column 을 blank space 로 여기도록
    만들려면 ?
    : PRESERVE BLANKS를 사용하지 않으면 loader 는 blank 들을 null 로
    인식한다.
    이 경우 workaround 로는
    예제)
    load data
    infile *
    into table test
    fields terminated by ','
    (col1 position(1:5) integer external,
    col2 position(15:20) char "nvl(:col2,' ')",
    col3 position(25:30) integer external)
    begindata
    12345 rec1 12345
    12345 23453
    23333 rec3 29874
    98273 98783
    98723 rec5 234
    SQL> select * from test yields;
    COL1 COL2 COL3
    12345 rec1 12345
    12345 23453
    23333 rec3 29874
    98273 98783
    98723 rec4 234
    5 rows selected.
    15) WHEN 절은 어떻게 사용한가 ?
    예제)
    load data
    infile *
    truncate
    into table t1
    when col1 = '12345'
    (col1 position(1:5) integer external, col2 position(7:12) char)
    into table t2
    when col1 = '54321'
    (col1 position(1:5) integer external, col2 position(7:12) char)
    begindata
    12345 table1
    54321 table2
    99999 no tab
    12345 table2
    54321 table2
    SQL> select * from t1;
    COL1 COL2
    12345 table1
    12345 table2
    SQL> select * from t2;
    COL1 COL2
    54321 table2
    54321 table2
    16) WHEN 절에 OR 를 사용할수 있는가 ?
    : 불가능하다 그러나 workaround 로는
    예제) 만일 where (col1=12345 OR col1=54321) AND col2='rowena'경우에
    data 를 insert 하고자 하면
    load data
    infile *
    truncate
    into table test
    when col1 = '12345' and col2='rowena'
    (col1 position(1:5) integer external, col2 position(7:12) char)
    into table test
    when col1 = '54321' and col2='rowena'
    (col1 position(1:5) integer external, col2 position(7:12) char)
    begindata
    12345 rowena
    43234 rowena
    54321 rowena
    (즉, OR를 갖지 못하나, 같은 table 에 두개의 when 은 가질수있다.)
    SQLDBA> select * from test;
    COL1 COL2
    12345 rowena
    54321 rowena
    2 rows selected.
    17) delimiter 로 ','를 사용하였는데 data 에 ','가 포함된 경우는 ?
    : 두 번 지정한다.
    예제)
    load 할 data 가 col1, rowena, rowena, col3 이고
    datafile 이 다음과 같은 경우
    col1, rowena,, rowena, col3
    select * from table:
    COL1 COL2 COL3
    col1 rowena, rowena col3
    18) 어떻게 하면 commit 을 덜 사용할 수 있나 ?
    : rows 나 bindsize를 사용한다.
    그러나 bindsize 가 적은 경우 bindsize는 rows 를 많이 적재할 수
    있으므로 항상 1 bindsize 에 몇 개의 rows 가 set 되었는지에 관계
    없이 bindsize에 commit 이 수행된다.
    Reference Document
    ------------------

    hi,
    pls take a look at this document
    http://www.petefinnigan.com/weblog/archives/00000020.htm
    regards,

  • ORA-12899 error from function invoked from SQL*Loader

    I am getting the above error when I call a function from my SQL*Loader script, and I am not seeing what the problem is. As far as I can see, there should be no problem with the field lengths, unless the length of the automatic variable within my function is somehow being set at 30? Here are the details (in the SQL*Loader script, the field of interest is the last one):
    ====
    Error:
    ====
    Record 1: Rejected - Error on table TESTM8.LET_DRIVE_IN_FCLTY, column DIF_CSA_ID.
    ORA-12899: value too large for column "TESTM8"."LET_DRIVE_IN_FCLTY"."DIF_CSA_ID" (actual: 30, maximum: 16)
    =======
    Function:
    =======
    CREATE OR REPLACE FUNCTION find_MCO_id (di_oid_in DECIMAL)
    RETURN CHAR IS mco_id CHAR;
    BEGIN
    SELECT AOL_MCO_LOC_CD INTO mco_id
    FROM CONV_DI_FLCTY
    WHERE DIF_INST_ELMNT_OID = di_oid_in;
    RETURN TRIM(mco_id);
    END;
    ==============
    SQL*Loader Script:
    ==============
    LOAD DATA
    INFILE 'LET_DRIVE_IN_FCLTY.TXT'
    BADFILE 'LOGS\LET_DRIVE_IN_FCLTY_BADDATA.TXT'
    DISCARDFILE 'LOGS\LET_DRIVE_IN_FCLTY_DISCARDDATA.TXT'
    REPLACE
    INTO TABLE TESTM8.LET_DRIVE_IN_FCLTY
    FIELDS TERMINATED BY '~' OPTIONALLY ENCLOSED BY '"'
    DIF_DRIVE_IN_OID DECIMAL EXTERNAL,
    DIF_FCLTY_TYPE_OID DECIMAL EXTERNAL NULLIF DIF_FCLTY_TYPE_OID = 'NULL',
    DIF_INST_ELMNT_OID DECIMAL EXTERNAL,
    DIF_PRI_PERSON_OID DECIMAL EXTERNAL NULLIF DIF_PRI_PERSON_OID = 'NULL',
    DIF_SEC_PERSON_OID DECIMAL EXTERNAL NULLIF DIF_SEC_PERSON_OID = 'NULL',
    DIF_CREATE_TS TIMESTAMP "yyyy-mm-dd-hh24.mi.ss.ff6",
    DIF_LAST_UPDATE_TS TIMESTAMP "yyyy-mm-dd-hh24.mi.ss.ff6",
    DIF_ADP_ID CHAR NULLIF DIF_ADP_ID = 'NULL',
    DIF_CAT_CLAIMS_IND CHAR,
    DIF_CAT_DIF_IND CHAR,
    DIF_DAYLT_SAVE_IND CHAR,
    DIF_OPEN_PT_TM_IND CHAR,
    DIF_CSA_ID CONSTANT "find_MCO_id(:DIF_DRIVE_IN_OID)"
    ============
    Table Definitions:
    ============
    SQL> describe CONV_DI_FLCTY;
    Name Null? Type
    DIF_INST_ELMNT_OID NOT NULL NUMBER(18)
    AOL_MCO_LOC_CD NOT NULL VARCHAR2(3)
    SQL> describe LET_DRIVE_IN_FCLTY;
    Name Null? Type
    DIF_DRIVE_IN_OID NOT NULL NUMBER(18)
    DIF_INST_ELMNT_OID NOT NULL NUMBER(18)
    DIF_FCLTY_TYPE_OID NUMBER(18)
    DIF_ADP_ID VARCHAR2(10)
    DIF_CAT_DIF_IND NOT NULL VARCHAR2(1)
    DIF_CAT_CLAIMS_IND NOT NULL VARCHAR2(1)
    DIF_CSA_ID VARCHAR2(16)
    DIF_DAYLT_SAVE_IND NOT NULL VARCHAR2(1)
    DIF_ORG_ENTY_ID VARCHAR2(16)
    DIF_OPEN_PT_TM_IND NOT NULL VARCHAR2(1)
    DIF_CREATE_TS NOT NULL DATE
    DIF_LAST_UPDATE_TS NOT NULL DATE
    DIF_ITM_FCL_MKT_ID NUMBER(18)
    DIF_PRI_PERSON_OID NUMBER(18)
    DIF_SEC_PERSON_OID NUMBER(18)
    =========================
    Thanks for any help with this one!

    I changed one line of the function to:
    RETURN CHAR IS mco_id VARCHAR2(16);
    But I still get the same error:
    ORA-12899: value too large for column "TESTM8"."LET_DRIVE_IN_FCLTY"."DIF_CSA_ID" (actual: 30, maximum: 16)
    I just am not seeing what is being defined as 30 characters. Any ideas much appreciated!

Maybe you are looking for