A reader, May 13, 2003 - 6:07 pm UTC
A reader, May 19, 2003 - 2:30 pm UTC
Su Baba, May 12, 2004 - 2:07 pm UTC
Hi Tom,
I'm running into some issues with a SQL*Loader control file. In my data file, I have the following columns:
column1 = organization_name
column2 = attribute1_value
column3 = attribute1_value2
column4 = attribute1_value3
column5 = attribute2_value
You can see the actual data in the control file below.
The table I'm trying to load into is defined as follows:
CREATE TABLE interface_table
(
organization_name VARCHAR2(100),
attribute1_name VARCHAR2(50),
attribute1_value VARCHAR2(100),
attribute2_name VARCHAR2(50),
attribute2_value VARCHAR2(100)
);
Here's my control file. I'd like to concatenate attribute1_value, attribute1_value2, attribute1_value3 columns from the data file and load them into attribute1_value column in the table. I'd also like to default attribute1_name and attribute2_name columns in the table to certain default values (e.g. "PARTNER TYPE" and "ANNUAL REVENUE").
LOAD DATA
INFILE *
INTO TABLE interface_table
TRUNCATE
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
organization_name,
attribute1_value ":attribute1_value || +++ || :attribute1_value2|| +++ || :attribute1_value3",
attribute1_value2 FILLER,
attribute1_value3 FILLER,
attribute2_value,
attribute1_name "PARTNER TYPE",
attribute2_name "ANNUAL REVENUE"
)
BEGINDATA
Best Organization,Reseller,VAD,OEM,25000000
interface_table should look like this after the data is loaded:
organization_name attribute1_name attribute1_value attribute2_name attribute2_value
----------------- --------------- -------------------- --------------- ----------------
Best Organization PATNER TYPE Reseller+++VAD+++OEM ANNUAL REVENUE 25000000
However, when I ran the SQL*Loader, I got the following error:
SQL*Loader: Release 8.0.6.3.0 - Production on Wed May 12 10:43:14 2004
(c) Copyright 1999 Oracle Corporation. All rights reserved.
SQL*Loader-350: Syntax error at line 11.
Expecting "," or ")", found "FILLER".
attribute1_value2 FILLER,
Can you shed some light on this? Also is my logic correct?
thanks
May 13, 2004 - 8:58 am UTC
FILLER is a keyword that way back when was "new" to Oracle8i release 1.
It was not available in 8.0.6
see
</code>
http://asktom.oracle.com/~tkyte/SkipCols/index.html <code>
you can use the 8.0 technique outlined for skipping columns to process the data..
Su Baba, May 13, 2004 - 1:13 pm UTC
I have SQL*Loader 9.2.0.1.0 installed on my system now.
Back to the originally question, somehow I am still not able to do what I want to do. I'd like to skip some columns in the data file (using FILLER). For the skipped columns, I want to concatenat them and put them into one single column. Here's the control file:
LOAD DATA
INFILE *
INTO TABLE interface_table
TRUNCATE
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
organization_name,
attribute1_value ":attribute1_value || :attribute1_value2 || :attribute1_value3",
attribute1_value2 FILLER,
attribute1_value3 FILLER,
attribute2_value,
attribute1_name "'PARTNER TYPE'",
attribute2_name "'ANNUAL REVENUE'"
)
BEGINDATA
Best Organization,Reseller,VAD,OEM,25000000
I got the following error from the above control file:
SQL*Loader: Release 9.2.0.1.0 - Production on Thu May 13 09:44:09 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL*Loader-291: Invalid bind variable ATTRIBUTE1_VALUE2 in SQL string for column
ATTRIBUTE1_VALUE.
It seems that the columns that are marked as FILLER cannot be used anywhere else. Is there a solution to this problem?
Thanks
May 13, 2004 - 3:06 pm UTC
use
BOUNDFILLER
instead of just filler and it'll bind the filler attributes into the insert statement as well.
Su Baba, June 02, 2004 - 2:05 pm UTC
June 02, 2004 - 2:20 pm UTC
it does that?
I mean, if you use that, you can access any column from the input (or not) at any time.
INFILE '-' parameter
jianhui, July 30, 2004 - 3:24 pm UTC
Tom,
I have seen some people put
INFILE '-' (a dash in sigle quote)
in their sqlldr control file. Then they can do something like this:
cat mydatafile.dat | sqlldr userid=u/p@tns control=my.ctl
and it works well. But I couldnt find this being documented in the Oracle Utility Guide, could you explain how this works? Or is it an undocumented but wellknown trick? It seems '-' is a magic switch that allows sqlldr to accept input data from stdio redirection.
Thanks!
July 30, 2004 - 6:09 pm UTC
i've never seen it personally -- but i would just:
sqlldr userid=u/p control=my.ctl DATA=mydatafile.dat
for piping data into sqlldr, i've always used a named pipe -- mknod -p
Mutiple Layout formats
Eashwer Iyer, February 07, 2007 - 6:24 pm UTC
Help - How can I load this using SQL*LOADER ?
how do I build in dynamism into the control files ?
The name of the incoming file is not going to tell me if the file is one of these 5 formats.
Notice that only the last 3 or 4 fields are different... but there is no clue for me, to say which format the SQL*LOADER script is to expect.
ACCNT_ID, PHONE, PROGRAM, LIST_DATE, START_DATE, MESSAGE_CELL, MIN4, ALT_NUMBER
ACCNT_ID, PHONE, PROGRAM, LIST_DATE, START_DATE, MESSAGE_CELL, TRANS_DATE, MIN4, ALT_NUMBER
ACCNT_ID, PHONE, PROGRAM, LIST_DATE, START_DATE, MESSAGE_CELL
ACCNT_ID, PHONE, PROGRAM, LIST_DATE, START_DATE, MESSAGE_CELL., TRANS_DATE, MIN4
ACCNT_ID, PHONE, PROGRAM, LIST_DATE, START_DATE, MESSAGE_CELL, MIN4
February 07, 2007 - 7:25 pm UTC
eh? and if you cannot tell, how do you expect sqlldr to be able to tell??????
To: Eashwer Iyer
Tom Fox, February 08, 2007 - 7:33 am UTC
If you are on Unix, why not write several .ctl files for each scenario? Then you could, if comma delimited:
head -n 1 <data file> | awk -F, '{print $NF}'
That will print the last field, and you can check for syntax of the field. After you determine that, you can pick the appropriate .ctl file to use.
Almost forgot
Tom Fox, February 08, 2007 - 7:35 am UTC
To check other fields you can:
Next to last field:
head -n 1 <data file> | awk -F, '{print $(NF-1)}'
Third from last field:
head -n 1 <data file> | awk -F, '{print $(NF-2)}'
and so on, so you can check any of those last fields.
Better yet, do they include column headings? We have a vendor ship with column headings so we can see what columns are in the file, then we strip the column headings before loading.
A reader, November 30, 2009 - 1:32 am UTC