SQL Loader :variant number of field and delimeiter .
I want to load data into table using SQL LOADER.
Challenge I am facing is fields are separated either by ',' or '.'
Eg:x0,y0,z0,a0.b0.c0.d0,p1,q1,r1
x1,y1,z1,a1.b1.c1,p1,q1
ie, the whole field, which contain '.' can be a join of any numebr of fields of maximum 30
ie the field a0.b0.c0.d0 => would be any number of fields separated by '.'
How to load these details into a table
Thanks in advance,
Arya Sreedhar.
Wouldn't it be better to process a decent file (with a single delimiter) instead of trying to fix the layout of an undecent file?
Similar Messages
-
SQL*LOADER(8I) VARIABLE SIZE FIELD를 여러 TABLE에 LOAD하기 (FILLER)
제품 : ORACLE SERVER
작성날짜 : 2004-10-29
==================================================================
SQL*LOADER(8I) VARIABLE SIZE FIELD를 여러 TABLE에 LOAD하기 (FILLER)
==================================================================
PURPOSE
SQL*LOADER 에서 variable length record와 variable size field를 가진 data
file 을 여러 table에 load하는 방법을 소개하고자 한다.
( 8i new feature인 FILLER 절 사용)
Explanation
SQL*LOADER SYNTAX
여러 table에 load하고자 할때에는 control file에 아래와 같이 하면 된다.
INTO TABLE emp
INTO TABLE emp1
fixed length field을 가진 data file을 여러 table에 같은 data을 load하고자
한다면 아래와 같다.
INTO TABLE emp
(empno POSITION(1:4) INTEGER EXTERNAL,
INTO TABLE emp1
(empno POSITION(1:4) INTEGER EXTERNAL,
위와 같이 양쪽 table의 empno field에 각각의 load할 data로부터 1-4까지를
load 할수 있다. 그러나 field의 길이가 가변적이라면 위와 같이 POSITION 절을
각 field에 사용할 수 없다.
Example
예제 1>
create table one (
field_1 varchar2(20),
field_2 varchar2(20),
empno varchar(10) );
create table two (
field_3 varchar2(20),
empno varchar(10) );
load할 record가 comma로 나누어지며 길이가 가변적이라고 가정하자.
<< data.txt >> - load할 data file
"this is field 1","this is field 2",12345678,"this is field 4"
<< test.ctl >> - control file
load data infile 'data.txt'
discardfile 'discard.txt'
into table one
replace
fields terminated by ","
optionally enclosed by '"' (
field_1,
field_2,
empno )
into table two
replace
fields terminated by ","
optionally enclosed by '"' (
field_3,
dummy1 filler position(1),
dummy2 filler,
empno )
dummy1 field는 filler로 선언되었다. filler로 선언하면 table에 load하지 않는다.
two라는 table에는 dummy1이라는 field는 없으며 position(1)은 current record의
처음부터 시작해서 첫번째 field을 dummy1 filler item에 load한다는 것을 말한다.
그리고 두번째 field을 dummy2 filler item에 load한다. 세번째 field인, one이라는
table에 load되었던 employee number는 two라는 table에도 load되는 것이다,
<< 실행 >>
$sqlldr scott/tiger control=test.ctl data=data.txt log=test.log bindsize=300000
$sqlplus scott/tiger
SQL> select * from one;
FIELD_1 FIELD_2 EMPNO
this is field 1 this is field 2 12345678
SQL> select * from two;
FIELD_3 EMPNO
this is field 4 12345678
예제 2>
create table testA (c1 number, c2 varchar2(10), c3 varchar2(10));
<< data1.txt >> - load할 data file
7782,SALES,CLARK
7839,MKTG,MILLER
7934,DEV,JONES
<< test1.ctl >>
LOAD DATA
INFILE 'data1.txt'
INTO TABLE testA
REPLACE
FIELDS TERMINATED BY ","
c1 INTEGER EXTERNAL,
c2 FILLER CHAR,
c3 CHAR
<< 실행 >>
$ sqlldr scott/tiger control=test1.ctl data=data1.txt log=test1.log
$ sqlplus scott/tiger
SQL> select * from testA;
C1 C2 C3
7782 CLARK
7839 MILLER
7934 JONES
Reference Documents
<Note:74719.1> -
SQL*Loader: How to use Sequence and REF together?
Hi,
I'm getting the following error:
SQL*Loader-418: Bad datafile datatype for column AREA_ID.
I attempt to upload one datafile into 4 different tables.
When executing sqlldr scott/tiger control=sqlldr_aj_new.ctl
1) Here is my Control file (sqlldr_aj_new.ctl):
load data
infile 'TST_MAIN_NEW.csv'
-- Loads table "TST_AREAS"
into table TST_AREAS
REPLACE
FIELDS TERMINATED by ','
(AREA_ID SEQUENCE,
AREA_NAME,
PRODUCT_ID,
PRIORITY_ID,
PLAN_ID,
CREATED_BY_ID,
AREA_DESC)
-- Loads table "TST_TEMPLATE_SCENS"
into table TST_TEMPLATE_SCENS
REPLACE
FIELDS TERMINATED by ','
(TEMPLATE_SCEN_ID SEQUENCE,
SCENARIO_NAME,
MODIFIED_BY_ID,
SCEN_TYPE_ID,
OWNER_ID,
PRIORITY_ID,
SCOPE_ID,
SCENARIO_DESC,
AREA_ID REF(CONSTANT 'TST_AREAS', AREA_ID))
2) Here is my data file(TST_MAIN_NEW.csv)
B/S,105,1,plan_id_1,2222,area_desc1,CCEMC_PR_001,1111,1,2222,2,1,scenario_desc_1
B/S,105,1,plan_id_2,2222,area_desc2,CCEMC_PR_002,1111,2,2222,2,2,scenario_desc_2
3) Here are the tables:
TST_AREAS
Name Null? Type
AREA_ID NOT NULL NUMBER(35)
AREA_NAME CHAR(64)
PRODUCT_ID NUMBER(35)
PRIORITY_ID NUMBER(35)
PLAN_ID NUMBER(35)
CREATED_BY_ID NUMBER(35)
AREA_DESC CHAR(1000)
TST_TEMPLATE_SCENS
Name Null? Type
TEMPLATE_SCEN_ID NOT NULL NUMBER(35)
SCENARIO_NAME CHAR(500)
MODIFIED_BY_ID NUMBER(35)
SCEN_TYPE_ID NUMBER(35)
OWNER_ID NUMBER(35)
PRIORITY_ID NUMBER(35)
SCOPE_ID NUMBER(35)
SCENARIO_DESC CHAR(1000)
AREA_ID NOT NULL NUMBER(35)
Please advise what is the reason for an error.
Thank you very much!
AndreyI don't think so.
SQL> create table t (
2 rowid number);
rowid number)
ERROR at line 2:
ORA-00904: : invalid identifierPlease post your version number and the DDL for the table.
Best practice in Oracle is to NEVER, EVER, store a ROWID: They can change.
After you have solved the first problem, that you've never actually built the table, the solution to the sequence use is to make the call in your DML.
INSERT INTO t (testcol) VALUES (<sequence_name>.NEXTVAL); -
Sql Loader fails with newline fields
Hi,I have a csv file delimited by "|" which is exported from MS Access. One of the fields contains a newline (e.g. notes column) which sql loader treats as beginning of new record. Can anyone tell me how to force the loader to ignore this newline.Is there a way I can tell the loader to read the optional '"' and continue with the record till it finds a closing '"'? Or is there a way to export data from access an force it to skip newlines and make a flat file with one record per line? I hate fixed length columns since it adds up pain in wrting the control files. Also the loader still fails to read the record if it encounters a newline as discussed above.
ThanksUnfortunately there is no command that can make sql*loader treat two lines in a text file as one record. Some one asked tom kyte same question, see what he had to say about it:
http://asktom.oracle.com/pls/ask/f?p=4950%3A8%3A%3A%3A%3A%3AF4950_P8_DISPLAYID%3A4972732303253
Why don't you create a staging table where you first load the data, and then from the data inserted into this table populate your original table in the form required.
Anwar -
SQL Loader: Total number of record read
Hello,
When we use SQL loader to load a data file, the total number of records read is output to the SQL Loader log. Is there a way to output this number to an oracle table?
Regardsslsam01 wrote:
Thank you Hans.
Can you provide me more information about loading SQL loader log file (e.g., control file) and point me to an example of loading SQL loader log files to Oracle table?
Regards,Oh joy, oh bliss. A documentation request.
For Oracle 10g, http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/part_ldr.htm#i436326 provides a few pages (including examples called Case Studies) -
SQL Loader error number 1 in OWB 9.0.4
I'm trying to execute a flat-file to database table mapping (using SQL*Loader), having set up my locations & connectors. When I execute the mapping, I get the following message:
Starting Execution COM_COM_MT_STG
Starting Task COM_COM_MT_STG
RPE-1013-SQL_LOADER_ERROR SQL Loader reported error condition, number 1.
Completing Task COM_COM_MT_STG
Completing Execution COM_COM_MT_STG
What does that mean and how do I fix it?
Also, is there any detailed documentation on building such a mapping, that can take you through all the steps, from creating the flat file module to deployment?
Thanks,
CareyCarey,
Use the runtime audit browser to access the error log. It will show you what went wrong. You may have to re-register your flat file location with a folder separator at the end... This is a bug.
Thanks,
Mark. -
SQL*Loader: Skipping input files fields
There were several postings here addressing an issue of skipping fields from the input file when using SQL*Loader. Most suggestions were to use FILLER fields.
Is there any other way? My input file (over which I have no control) has literally hundreds of fields, most of them blanks. To write a control file with this many dummy fields will be difficult (I can write a perl script to do it, I know, I know...).
Thanks for any suggestions.Hi, I think in your case the best tool for you use is pl/sql. Cause have function called Utl_file, there you have more control to do this type of load, and you can combine another functions.
Paulo Sergio -
SQL Loader Constraints with Column Objects and Nested Tables
I am working on loading a Table that (god forbid) contains columns, column objects, and nested tables (which contains several depth of column objects). My question is does SQL Loader have a hidding undocumented feature where it states how the column objects must be grouped in refereneced to the nested tables within the loader file? I can load the various column objects, and nested tables fine right now, however, I am loading them all in strange and insane order. Can anyone answer this question? Thanks.
PeterI just noticed that my email is wrong. If you can help, plese send email to [email protected]
thanks. -
How to dynamically load any number of VIs and spawn a new thread for each
Hi,
I'm trying to spawn several TCP listening threads, the number of which is dynamic based upon a configuration file which is read at runtime. With with the included code, I am attempting to open and call these listening threads from a for loop, thinking I could run through all the calls I need to make and be finished. However, since the subVI I'm calling (wait_for_and_process_messages.vi) runs a continuous while loop, the for loop in the parent VI does not continue as it is waiting for the first call to finish.
How can I design this to simply spawn off a thread each time I call the subVI and continue? The idea is to allow the number of threads be dynamic so it is not so easy compared to knowing the number of needed threads ahead of time. However, I do need to feed data to each call's nodes so I can't just use the "run" method unless there's a way to feed data to the nodes while using "run."
Attachments:
database_communicator.vi 12 KBCheck out this Nugget.
It contains code that should help you get started.
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
Sql*loader and sequence() for primary keys
I have a question regarding SQL*Loader with the sequence() function and using it for a primary key to load records in multiple tables from one input record. I am pulling data from a delimited file and populating several tables from each row. For the primary key, I am using the sequence function.
For the first table (the parent), I use sequence(40000,1) for the key. Since the remaining inserts are based on the same logical record, I use sequence(40000,1) for those too (one record for each month). The problem comes in when a child record does not pass a WHEN clause (the amount is zero). Then it almost seems as if the parent record is not loaded and the child (or children) that does pass the WHEN clause are assigned to the next parent! Obviously, the sequence is getting out of sync between the children and the parent.
I've looked in the documentation and tried several different ways to attack this problem. Is there a bug in SQLLDR (8.1.7) or is it just my coding.
I will try to include the files below but they are very large.
Thanks for your help.
Dan
***CONTROL FILE***
LOAD DATA
INFILE 'rent.csv'
INTO TABLE BUDGET_LINE
append
WHEN TOT_AMT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER CHAR,
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
APR_AMT FILLER CHAR,
APR_CNT FILLER CHAR,
MAY_AMT FILLER CHAR,
MAY_CNT FILLER CHAR,
JUN_AMT FILLER CHAR,
JUN_CNT FILLER CHAR,
JUL_AMT FILLER CHAR,
JUL_CNT FILLER CHAR,
AUG_AMT FILLER CHAR,
AUG_CNT FILLER CHAR,
SEP_AMT FILLER CHAR,
SEP_CNT FILLER CHAR,
OCT_AMT FILLER CHAR,
OCT_CNT FILLER CHAR,
NOV_AMT FILLER CHAR,
NOV_CNT FILLER CHAR,
DEC_AMT FILLER CHAR,
DEC_CNT FILLER CHAR,
CUT FILLER CHAR,
NETMANGEN FILLER CHAR,
NETMAN_item BOUNDFILLER CHAR,
NETMAN_item_seq BOUNDFILLER CHAR,
NETMAN_location BOUNDFILLER CHAR,
UPDATED_ON DATE "MM/DD/YYYY",
NETMAN_com_desc BOUNDFILLER CHAR,
NETMAN_vendor BOUNDFILLER CHAR,
NETMAN_generation BOUNDFILLER CHAR,
CREATED_ON SYSDATE,
CREATED_BY CONSTANT '0',
UPDATED_BY CONSTANT '0',
ACTIVE CONSTANT 'T',
GL_CODE_COMBO_ID CONSTANT '0',
BUDGET_TYPE CONSTANT 'B',
AMOUNT_TYPE CONSTANT 'D',
source constant 'N',
BUDGET_LINE_ID SEQUENCE(40000,1),
DESCRIPTION "(:NETMAN_item)||'-'||(:NETMAN_item_seq)||'; '||:NETMAN_com_desc||'; '||:NETMAN_vendor||' ('||:NETMAN_generation||')'"
INTO TABLE GL_CODE_TEMP
append
WHEN TOT_AMT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
SPENDER CHAR ,
ACCT CHAR ,
TOT_AMT FILLER CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '1',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '2',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '3',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '4',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '5',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
APR_AMT FILLER CHAR,
APR_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '6',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
APR_AMT FILLER CHAR,
APR_CNT FILLER CHAR,
MAY_AMT FILLER CHAR,
MAY_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '7',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
APR_AMT FILLER CHAR,
APR_CNT FILLER CHAR,
MAY_AMT FILLER CHAR,
MAY_CNT FILLER CHAR,
JUN_AMT FILLER CHAR,
JUN_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '8',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
APR_AMT FILLER CHAR,
APR_CNT FILLER CHAR,
MAY_AMT FILLER CHAR,
MAY_CNT FILLER CHAR,
JUN_AMT FILLER CHAR,
JUN_CNT FILLER CHAR,
JUL_AMT FILLER CHAR,
JUL_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '9',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
APR_AMT FILLER CHAR,
APR_CNT FILLER CHAR,
MAY_AMT FILLER CHAR,
MAY_CNT FILLER CHAR,
JUN_AMT FILLER CHAR,
JUN_CNT FILLER CHAR,
JUL_AMT FILLER CHAR,
JUL_CNT FILLER CHAR,
AUG_AMT FILLER CHAR,
AUG_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '10',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
APR_AMT FILLER CHAR,
APR_CNT FILLER CHAR,
MAY_AMT FILLER CHAR,
MAY_CNT FILLER CHAR,
JUN_AMT FILLER CHAR,
JUN_CNT FILLER CHAR,
JUL_AMT FILLER CHAR,
JUL_CNT FILLER CHAR,
AUG_AMT FILLER CHAR,
AUG_CNT FILLER CHAR,
SEP_AMT FILLER CHAR,
SEP_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '11',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
APR_AMT FILLER CHAR,
APR_CNT FILLER CHAR,
MAY_AMT FILLER CHAR,
MAY_CNT FILLER CHAR,
JUN_AMT FILLER CHAR,
JUN_CNT FILLER CHAR,
JUL_AMT FILLER CHAR,
JUL_CNT FILLER CHAR,
AUG_AMT FILLER CHAR,
AUG_CNT FILLER CHAR,
SEP_AMT FILLER CHAR,
SEP_CNT FILLER CHAR,
OCT_AMT FILLER CHAR,
OCT_CNT FILLER CHAR,
AMOUNT CHAR
INTO TABLE BUDGET_COST
append
WHEN AMOUNT != '0'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
NETMAN_ITEM_NO FILLER POSITION(1) CHAR TERMINATED BY ',',
BUDGET_LINE_ID SEQUENCE(40000,1),
PERIOD_ID CONSTANT '12',
SPEND FILLER CHAR,
ACCOUNT FILLER CHAR,
TOT_AMT FILLER CHAR,
JAN_AMT FILLER CHAR,
JAN_CNT FILLER CHAR,
FEB_AMT FILLER CHAR,
FEB_CNT FILLER CHAR,
MAR_AMT FILLER CHAR,
MAR_CNT FILLER CHAR,
APR_AMT FILLER CHAR,
APR_CNT FILLER CHAR,
MAY_AMT FILLER CHAR,
MAY_CNT FILLER CHAR,
JUN_AMT FILLER CHAR,
JUN_CNT FILLER CHAR,
JUL_AMT FILLER CHAR,
JUL_CNT FILLER CHAR,
AUG_AMT FILLER CHAR,
AUG_CNT FILLER CHAR,
SEP_AMT FILLER CHAR,
SEP_CNT FILLER CHAR,
OCT_AMT FILLER CHAR,
OCT_CNT FILLER CHAR,
NOV_AMT FILLER CHAR,
NOV_CNT FILLER CHAR,
AMOUNT CHAR
*** PIECE OF DATA FILE ***
Item,Spender,Account,Total Amt,Jan Amt,Jan Count,Feb Amt,Feb Count,Mar Amt,Mar Count,Apr Amt,Apr Count,May Amt,May Count,Jun Amt,Jun Count,Jul Amt,Jul Count,Aug Amt,Aug Count,Sep Amt,Sep Count,Oct Amt,Oct Count,Nov Amt,Nov Count,Dec Amt,Dec Count,Status,Netman Gen,Netman Item,Netman Unit,Location,Last Update Date,Component Description,Vendor Description,Generation Process
10110993,10993,8301-01,90134,7480,0,7480,0,7480,0,7480,0,7480,0,7480,0,7480,0,7480,0,7480,0,7480,0,7667,0,7667,0,0,+,LEASE PYMT,207,WIMOS,5/22/2002,LEASE PAYMENTS,"VIKING HOLDING, INC.",ACTUAL BUDGET
10410993,10993,8301-04,15240,1270,0,1270,0,1270,0,1270,0,1270,0,1270,0,1270,0,1270,0,1270,0,1270,0,1270,0,1270,0,0,+,JANITORIAL,58,WIMOS,5/22/2002,JANITORIAL,BUILDING ONE SVC SOLUTION,ACTUAL BUDGET
10810993,10993,8301-08,2232,186,0,186,0,186,0,186,0,186,0,186,0,186,0,186,0,186,0,186,0,186,0,186,0,0,+,ELECTRIC,77,WIMOS,5/22/2002,"UTILITIES (GAS,ELEC.,ETC)",WISCONSIN PUBLIC SERVICE,AVGD 01 04 07 10 NOT WEIGHTED
10910993,10993,8301-09,4220,26,0,348,0,609,0,383,0,348,0,371,0,348,0,371,0,360,0,348,0,360,0,348,0,0,+,FIRE EQUIP,51,WIMOS,5/22/2002,RENT CONTRACT SERVICES,"CENTRALCOM, INC.",ACTUAL EXPERIENCE
11610993,10993,8301-16,1272,106,0,106,0,106,0,106,0,106,0,106,0,106,0,106,0,106,0,106,0,106,0,106,0,0,+,L/H MOSINE,1,WIMOS,5/22/2002,LEASEHOLD IMPROVEMENTS,ELLIS STONE,ACTUAL BUDGET
10110994,10994,8301-01,69960,5830,0,5830,0,5830,0,5830,0,5830,0,5830,0,5830,0,5830,0,5830,0,5830,0,5830,0,5830,0,0,+,LEASE PYMT,228,WISTEWEL,5/22/2002,LEASE PAYMENTS,BJ INVESTMENTS LLC,ACTUAL BUDGET
10410994,10994,8301-04,840,70,0,70,0,70,0,70,0,70,0,70,0,70,0,70,0,70,0,70,0,70,0,70,0,0,+,JANITORIAL,69,WISTEWEL,5/22/2002,JANITORIAL,MARSDEN,ACTUAL BUDGET
10710994,10994,8301-07,6067,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6067,0,0,+,LEASE PYMT,228,WISTEWEL,5/22/2002,LEASE PAYMENTS,BJ INVESTMENTS LLC,ASSUME 5% INCREASE OVER ACTUAL 2000 EXPENSES
10810994,10994,8301-08,2460,205,0,205,0,205,0,205,0,205,0,205,0,205,0,205,0,205,0,205,0,205,0,205,0,0,+,ELECTRIC,84,WISTEWEL,5/22/2002,"UTILITIES (GAS,ELEC.,ETC)",BJ INVESTMENTS LLC,AVGD 03 06 09 NOT WEIGHTED
10910994,10994,8301-09,1050,70,0,70,0,105,0,105,0,70,0,105,0,35,0,140,0,35,0,70,0,210,0,35,0,0,+,SANITATION,12,WISTEWEL,5/22/2002,RENT CONTRACT SERVICES,WASTE MANAGEMENT OF WIS,ACTUAL EXPERIENCE
11910994,10994,8301-19,1099,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1099,0,0,0,0,0,0,0,0,0,0,+,INSURANCE,6,WISTEWEL,5/22/2002,INSURANCE,BJ INVESTMENTS LLC,ACTUAL EXPERIENCE
10110998,10998,8301-01,2440,2440,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+,LEASE PYMT,47,ILELG,5/22/2002,LEASE PAYMENTS,ELGIN AIRPORT BUSINESS PK,ACTUAL BUDGET
10410998,10998,8301-04,146,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+,LEASE PYMT,47,ILELG,5/22/2002,LEASE PAYMENTS,ELGIN AIRPORT BUSINESS PK,ACTUAL BUDGET
10610998,10998,8301-06,336,28,0,28,0,28,0,28,0,28,0,28,0,28,0,28,0,28,0,28,0,28,0,28,0,0,+,DRINK H2O,46,ILELG,5/22/2002,COOLER AND BOTTLED WATER,"HINCKLEY & SCHMITT, INC.",AVGD 01 02 03 04 05 06 07 08 09 10
10710998,10998,8301-07,276,276,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,+,LEASE PYMT,47,ILELG,5/22/2002,LEASE PAYMENTS,ELGIN AIRPORT BUSINESS PK,ASSUME 5% INCREASE OVER ACTUAL 2000 EXPENSES
10810998,10998,8301-08,3108,433,0,315,0,234,0,173,0,181,0,292,0,320,0,337,0,316,0,153,0,183,0,171,0,0,+,ELECTRIC,20,ILELG,5/22/2002,"UTILITIES (GAS,ELEC.,ETC)",COMMONWEALTH EDISON,AVGD 01 02 03 04 05 06 07 08 09 10 WEIGHTED
*** SCRIPT FOR TABLES LOADED ***
CREATE TABLE BUDGET_LINE (
BUDGET_LINE_ID NUMBER NOT NULL,
BUDGET_TYPE CHAR (1) NOT NULL,
GL_CODE_COMBO_ID NUMBER NOT NULL,
AMOUNT_TYPE CHAR (1) NOT NULL,
ACTIVE CHAR (1) DEFAULT 'T' NOT NULL,
SOURCE CHAR (1),
CUT CHAR (1),
DESCRIPTION VARCHAR2 (180),
CAP_ITEM_ID NUMBER,
PBT_ID NUMBER,
BILL_ID NUMBER,
CREATED_ON DATE DEFAULT SYSDATE NOT NULL,
CREATED_BY NUMBER NOT NULL,
UPDATED_ON DATE DEFAULT SYSDATE NOT NULL,
UPDATED_BY NUMBER NOT NULL,
CHECK (ACTIVE IN ('T','F') ) ,
CHECK (CUT IN ('C',NULL) ),
CONSTRAINT BUDGET_LINE_PRI
PRIMARY KEY ( BUDGET_LINE_ID ) ) ;
CREATE TABLE BUDGET_COST (
BUDGET_LINE_ID NUMBER NOT NULL,
PERIOD_ID NUMBER NOT NULL,
AMOUNT NUMBER (13,2),
CONSTRAINT BUDGET_COST_PRI
PRIMARY KEY ( BUDGET_LINE_ID, PERIOD_ID ) ) ;
CREATE TABLE GL_CODE_TEMP (
BUDGET_LINE_ID NUMBER NOT NULL,
SPENDER CHAR (5),
ACCT CHAR (7),
GL_CODE_COMBO_ID NUMBER,
CONSTRAINT GL_CODE_TEMP_BDGT_ID
PRIMARY KEY ( BUDGET_LINE_ID ) ) ;Thanks for the reply .. user do have their user credentials but only for the application ... but all users use a common loader and control file once they log into the application. So irrespective of which user is logged in he selects the same control file and loads to the same table mentioned in the control file .. i instead want user to be able to load to the table in control file but into his schema like username.tablename instead of just the tablename mentioned in .ctl file.
-
Problem with field-length in sql-loader
Hello,
(sorry I see it's the wrong forum -> SQL-Developer, I searched for SQL-Loader, is there a possibility to change the forum ?)
I can't find an answer for my question at google, so I hope there is someone in this forum who can help me.
I have a dat-File that contains 12 500 000 records and want to laod it via sql-loader. The first field contains the ID and there were numbers from 1 to 12 500 000 stored.
When I run the sql-loader, the ID run up to 9 999 999 and then, for the last 2 500 001 records, ist starts at 1 again.
I noticed a few things :
1. Numbers < 10 000 000 don't make Problems
2. Numbers >= 10 000 000 make Problems, the first digit ( in this example "1") is cut, so the number "10 000 001" ist stored as "1". It comes to double entries (IDs 1 to 2 500 000).
3. The same field-definition, I have for the third field of the record -> there is no Problem. THERE I can store any number.
4. I tried to store a number > 100 000 000 -> the first digit was cut too, but ONLY the first digit.
5. I'm able to store any number manually in the Database.
So, I have a problem with the first field. If the number is greater then 10 000 000, the first Number is cut. It doesn't make any differance, if the number is 10 000 000 or 999 999 999, just the first digit, in the first field, is cut.
Any idea ??????????
Here some infos :
Database :
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
SQL-PLUS :
SQL*Plus: Release 10.2.0.4.0 - Production
Script sqlldr :
sqlplus ${schema}/$2 <<EOF >>LOAD.LOG
set timing on
set echo on
set heading off
set heading on
!sqlldr userid=${schema}/$2 control=surface_geometry.ctl log=surface_geometry.log
exit
EOF
ctl-File :
LOAD DATA
INFILE imp_surface_geometry_test2
TRUNCATE
CONTINUEIF NEXT(1:1) = '#'
INTO TABLE SURFACE_GEOMETRY
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS (
ID INTEGER EXTERNAL ,
GMLID,
GMLID_CODESPACE,
PARENT_ID NULLIF PARENT_ID = BLANKS,
ROOT_ID NULLIF ROOT_ID = BLANKS,
IS_SOLID,
IS_COMPOSITE,
IS_TRIANGULATED,
IS_XLINK,
IS_REVERSE,
GEB_ID,
GEOMETRY COLUMN OBJECT
SDO_GTYPE INTEGER EXTERNAL,
SDO_SRID CONSTANT 31468,
SDO_ELEM_INFO VARRAY TERMINATED BY '|/'
(X FLOAT EXTERNAL),
SDO_ORDINATES VARRAY TERMINATED BY '|/'
(X FLOAT EXTERNAL)
Table-Definition (sql-File) :
CREATE TABLE SURFACE_GEOMETRY (
ID NUMBER,
GMLID VARCHAR2(256),
GMLID_CODESPACE VARCHAR2(1000),
PARENT_ID NUMBER,
ROOT_ID NUMBER,
IS_SOLID NUMBER(1,0),
IS_COMPOSITE NUMBER(1,0),
IS_TRIANGULATED NUMBER(1,0),
IS_XLINK NUMBER(1,0),
IS_REVERSE NUMBER(1,0),
GEB_ID CHAR(7),
GEOMETRY MDSYS.SDO_GEOMETRY,
CONSTRAINT c_unique_id UNIQUE (ID))
storage (initial 1M next 1M maxextents 1024) ;
Some Entries in the dat-File :
12556067| |XXX|12556066|12556066|0|0|0|0|0| |
#3003|1|1003|1|/
#4479400.000000|5333360.000000| 526.870000|4479380.000000|5333360.000000| 526.720000|4479400.000000|5333340.000000| 526.980000|4479400.000000|5333360.000000| 526.870000|/
12556068| |XXX| |12556068|0|0|1|0|0| |
#||/
#|/
12556069| |XXX|12556068|12556068|0|0|0|0|0| |
#3003|1|1003|1|/
#4479380.000000|5333380.000000| 526.600000|4479380.000000|5333360.000000| 526.720000|4479400.000000|5333360.000000| 526.870000|4479380.000000|5333380.000000| 526.600000|/
log-File : (100 records for the test)
SQL*Loader: Release 10.2.0.4.0 - Production on Fr Mai 28 15:16:43 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Kontrolldatei: surface_geometry.ctl
Datendatei: imp_surface_geometry_test.dat
Fehlerdatei: imp_surface_geometry_test.bad
Datei für zurückgewiesene Sätze: nichts spezifiziert
(alle Discards zulassen)
Zu ladende Anzahl: ALL
Zu überspringende Anzahl: 0
Zulässige Fehler: 50
Bind-Array: 64 Zeilen, maximal 256000 Bytes
Fortsetzung: 1:1 = 0X23(Zeichen '#'), im nächsten physischen Satz
Benutzer Pfad: Konventionell
Tabelle SURFACE_GEOMETRY, geladen von jedem logischen Satz.
Insert-Option in Kraft für diese Tabelle: TRUNCATE
Option TRAILING NULLCOLS ist wirksam
Spaltenname Position Läng Term Eing Datentyp
ID FIRST * | CHARACTER
GMLID NEXT * | CHARACTER
GMLID_CODESPACE NEXT * | CHARACTER
PARENT_ID NEXT * | CHARACTER
NULL wenn PARENT_ID = BLANKS
ROOT_ID NEXT * | CHARACTER
NULL wenn ROOT_ID = BLANKS
IS_SOLID NEXT * | CHARACTER
IS_COMPOSITE NEXT * | CHARACTER
IS_TRIANGULATED NEXT * | CHARACTER
IS_XLINK NEXT * | CHARACTER
IS_REVERSE NEXT * | CHARACTER
GEB_ID NEXT * | CHARACTER
GEOMETRY DERIVED * COLUMN OBJECT
*** Felder in GEOMETRY
SDO_GTYPE NEXT * | CHARACTER
SDO_SRID CONSTANT
Wert ist '31468'
SDO_ELEM_INFO DERIVED * VARRAY
Abschlusszeichenfolge : '|/'
*** Felder in GEOMETRY.SDO_ELEM_INFO
X FIRST * | CHARACTER
*** Feldende in GEOMETRY.SDO_ELEM_INFO
SDO_ORDINATES DERIVED * VARRAY
Abschlusszeichenfolge : '|/'
*** Felder in GEOMETRY.SDO_ORDINATES
X FIRST * | CHARACTER
*** Feldende in GEOMETRY.SDO_ORDINATES
*** Feldende in GEOMETRY
Tabelle SURFACE_GEOMETRY:
100 Zeilen erfolgreich geladen.
0 Zeilen aufgrund von Datenfehlern nicht geladen.
0 Zeilen nicht geladen, da alle WHEN-Klauseln fehlerhaft waren.
0 Zeilen nicht geladen, da alle Felder NULL waren.
Zugewiesener Bereich für Bind-Array: 232576 Bytes (64 Zeilen)
Byte in Lese-Puffer: 1048576
Gesamtzahl der übersprungenen logischen Datensätze: 0
Gesamtzahl der gelesenen logischen Datensätze: 100
Gesamtzahl der abgelehnten logischen Datensätze: 0
Gesamtzahl der zurückgewiesenen logischen Datensätze: 0
Lauf begonnen am Fr Mai 28 15:16:43 2010
Lauf beendet am Fr Mai 28 15:16:43 2010
Abgelaufene Zeit: 00:00:00.19
CPU-Zeit: 00:00:00.01
Edited by: user9338988 on 28.05.2010 06:21sorry, wrong forum. I opened the thread in forum "Export/Import/SQL-Loader & External Tables"
-
Skipping fields in SQL*LOADER data file
I have a data file that has more fields than the target table does. How can I write a SQL*LOADER control file to skip some fields in the middle of the text line?
nullIf you don't want to define input fields by position, the simplest way I think is to use FILLER fields.
Quoted from SQL*Loader doc:
"Specifying Filler Fields
Filler fields have names but they are not loaded into the table. However, filler fields can be used as arguments to init_specs (for example, NULLIF and DEFAULTIF) as well as to directives (for example, SID, OID, REF, BFILE). Also, filler fields can occur anyplace in the data file. They can be inside of the field list for an object or inside the definition of a VARRAY.
See SQL*Loader DDL Behavior and Restrictions for more information on filler fields and their use.
A sample filler field specification looks as follows:
field_1_count FILLER char,
Ex:
Regards,
Zoltan -
SQL Loader AND Temporary Tables
Hi :
Have a Couple of Questions..
(1) Is SQL Loader not part of the ORACLE DB 9.X?? Coz I could not find that exe.
(2) Can we have the Data file on the Client Machine?? OR is it mandatory that the data file should be on the Server to load the data?SQL loader is part of Oracle9i and you can use its driver to create external table.Moreover for external tables datafiles should be on server.
-
Hi all,
I am trying to insert this data into the CLOB column. I am getting the error - Records rejected.
Please help me in this regard.
Control file:
load data
infile 'c:\test.csv'
truncate
into table test_clob
fields terminated by ","
a ,
b
Table Structure:
create table test_clob(a number, b clob);
Test.csv:
1, "Marsh Supermarkets here is the exclusive supermarket partner of Project 18 a program it developed with the Peyton Manning Childrens Hospital and Ball State University to fight childhood obesity.
Project 18 Approved shelf tags identify better-for-you kid-friendly products throughout Marsh stores. Canned fruit frozen entrees vegetables granola bars and salty snacks are among the categories analyzed.
In the granola bar category for instance products can have no more than 35% of calories from total fat and have no more than 10% of calories from saturated and trans fats combined.
Along with shelf-tags at Marsh the initiative includes: Project 18 MVPs local high school students honored for serving as role models for younger children in the community; community wellness events Project 18 walks; a school curriculum; and The Project 18 Mobile Van."
Warm Regards
SwamiHi Swami,
You need to modify your control file like this:
load data
infile 'c:\test.csv'
TRUNCATE
into table test_clob
fields terminated by ","
a ,
b CHAR(4000)
)Reason for specifying CHAR(4000) is as under (from Oracle Documentation)
To load internal LOBs (BLOBs, CLOBs, and NCLOBs) or XML columns from a primary datafile, you can use the following standard SQL*Loader formats:
* Predetermined size fields
* Delimited fields
* Length-value pair fields
For more go here: Link: [http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_loading.htm#i1008564]
Thanks,
Ankur -
Loading "fixed length" text files in UTF8 with SQL*Loader
Hi!
We have a lot of files, we load with SQL*Loader into our database. All Datafiles have fixed length columns, so we use POSITION(pos1, pos2) in the ctl-file. Till now the files were in WE8ISO8859P1 and everything was fine.
Now the source-system generating the files changes to unicode and the files are in UTF8!
The SQL-Loader docu says "The start and end arguments to the POSITION parameter are interpreted in bytes, even if character-length semantics are in use in a datafile....."
As I see this now, there is no way to say "column A starts at "CHARACTER Position pos1" and ends at "Character Position pos2".
I tested with
load data
CHARACTERSET AL32UTF8
LENGTH SEMANTICS CHARACTER
replace ...
in the .ctl file, but when the first character with more than one byte encoding (for example ü ) is in the file, all positions of that record are mixed up.
Is there a way to load these files in UTF8 without changing the file-definition to a column-seperator?
Thanks for any hints - charlyI have not tested this but you should be able to achieve what you want by using LENGTH SEMANTICS CHARACTER and by specifying field lengths (e.g. CHAR(5)) instead of only their positions. You could still use the POSITION(*+n) syntax to skip any separator columns that contain only spaces or tabs.
If the above does not work, an alternative would be to convert all UTF8 files to UTF16 before loading so that they become fixed-width.
-- Sergiusz
Maybe you are looking for
-
I'm unable to install Coldfusion10 on IIS 7.5
I installed and reinstalled both the OS and ColdFusion10 several times. My default page (index.cfm in the root directory) is giving me a CF 404 Error Page with the message: The page you are trying to access could not be found. Please try again or n
-
Integration with Adobe Photoshop Elements 4
I would like to migrate to Adobe Photoshop Elements 4 for Mac and would like to know how it will integrate with iPhoto. My photos are stored in iPhoto, could I edit them using PE4? How should I generate slideshows? Do I use PE4 or iPhoto? Could I imp
-
How to manage a "nice" url if APEX uses web pl/sql and not Apache?
Hi all, How can I create a pretty url without using redirects or frames since APEX is using web pl/sql and not Apache? This is on version 4.0.1. We want the users to access the Apex App from a nice url without the traditional long url. Thanks, Veena.
-
when i click on a new tab it want it to go to my home page not "new tab". Under tabs in options there is no option to set a new tab to open my home page.
-
Analysis not working.. Clicks and Pops, etc.
I'm trying to remove clicks and pops, clipped signals and power line hum from an audio track (registered using an iPod mic in a big room so it's full of noises) with the latest Soundtrack Pro 2- I did a Noise Reduction then applied the following Anal