When clause in SQL Loader
hi,
i am facing a problem during when clause in sql loader
here is my control file
options(direct=true)
load data
infile 'data_file.txt'
truncate
into table "TABLE_NAME"
when col1 = '1'
trailing nullcols
col1 integer external TERMINATED BY ',',
col2 integer external )
into table "TABLE_NAME"
when col1 = '2'
trailing nullcols
col1 integer external TERMINATED BY ',' ,
col2 integer external )
=======================================
this file loads only data when col1=1 and does not load data when col1=2
can any body help me
thanks in advance
Hi,
I currently have the same problem. Seems that SQLLDR WHEN clause only apply for columns that based on datafile. Also, data that to be compared in WHEN clause is get from datafile and you can not make any modification on that data.
How did you do to work around with that?
Similar Messages
-
How to display list process, when i run sql*loader in c#
Hello,
How to display list process, when i run sql*loader in c#. I mean when i run sql*loader from cmd windows, i get list process how many row has been inserted. But when i run SQL*Loader from C#, i can't get process SQL*Loader.
This is my code:
string strCmd, strSQLLoader;
string strLoaderFile = "XLLOAD.CTL";
string strLogFile = "XLLOAD_LOG.LOG";
string strCSVPath = @"E:\APT\WorkingFolder\WorkingFolder\sqlloader\sqlloader\bin\Debug\8testskrip_HTTP.csv";
string options = "OPTIONS (SKIP=1, DIRECT=TRUE, ROWS=1000000,BINDSIZE=512000)";
string append = "APPEND INTO TABLE XL_XDR FIELDS TERMINATED BY ','";
string table = "OPTIONALLY ENCLOSED BY '\"' TRAILING NULLCOLS (xdr_id,xdr_type,session_start_time,session_end_time,session_last_update_time,session_flag,version,connection_row_count,error_code,method,host_len,host,url_len,url,connection_start_time,connection_last_update_time,connection_flag,connection_id,total_event_count,tunnel_pair_id,responsiveness_type,client_port,payload_type,virtual_type,vid_client,vid_server,client_addr,server_addr,client_tunnel_addr,server_tunnel_addr,error_code_2,ipid,c2s_pkts,c2s_octets,s2c_pkts,s2c_octets,num_succ_trans,connect_time,total_resp,timeouts,retries,rai,tcp_syns,tcp_syn_acks,tcp_syn_resets,tcp_syn_fins,event_type,flags,time_stamp,event_id,event_code)";
strCmd = "sqlldr xl/secreat@o11g control=" + strLoaderFile + " LOG=" + strLogFile;
System.IO.DirectoryInfo di;
try
System.Diagnostics.ProcessStartInfo cmdProcessInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe");
di = new DirectoryInfo(strCSVPath);
strSQLLoader = "";
strSQLLoader += "LOAD DATA INFILE '" + strCSVPath.ToString().Trim() + "' " + append + " " + table;
StreamWriter writer = new StreamWriter(strLoaderFile);
writer.WriteLine(strSQLLoader);
writer.Flush();
writer.Close();
// Redirect both streams so we can write/read them.
cmdProcessInfo.RedirectStandardInput = true;
cmdProcessInfo.RedirectStandardOutput = true;
cmdProcessInfo.UseShellExecute = false;
cmdProcessInfo.LoadUserProfile = true;
//System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
// Start the procses.
System.Diagnostics.Process pro = System.Diagnostics.Process.Start(cmdProcessInfo);
// Issue the dir command.
pro.StandardInput.WriteLine(strCmd);
// Exit the application.
pro.StandardInput.WriteLine("exit");
//Process[] processlist = Process.GetProcesses();
//foreach(Process pro in processlist){
Console.WriteLine("Process: {0} ID: {1}", pro.ProcessName, pro.Id);
Console.WriteLine(pro.StandardOutput.ReadLine());
// Read all the output generated from it.
string strOutput;
strOutput = pro.StandardOutput.ReadToEnd();
pro.Dispose();
catch (Exception ex)
return;
finally
Thanks.friend
sqlldr is an application residing in the OS. procedure runs in the dbms engine.
you cannot run an os command directly from a procedure or a function or a package .
If you want to do so you need to use either a daemon process created by a PRO*C program
or a JAVA stored procedure to do so.
just refer to previous question forums, you can find the solution. Somebody has already given a solution using
java to run an OS command . check it out
prakash
[email protected] -
Use of WHEN in SQL Loader Control File
Does anyone know of a way, using the CTL file below, to NOT LOAD (i.e. discard) any record where field G is null -OR- substr(G,1,3)='CON'+ (the first 3 characters of field G are "CON")?
The WHEN clause seems very limited in what it can test and all my attempts to use a compound condition, much less the SUBSTR function, have failed. The documentation indicates that only very simple conditions can be specified.
(Oracle 10g, Unix)
Thanks
LOAD DATA
TRUNCATE
INTO TABLE TEST_TABLE
WHEN (G <> '')
FIELDS TERMINATED BY "^"
TRAILING NULLCOLS
A ,
B FILLER,
C FILLER,
D FILLER,
E FILLER,
F FILLER,
G "LTRIM(:G,'0')",
H FILLER,
I FILLER,
J FILLER,
K SYSDATE,
L CONSTANT "SQLLDR"
)Hello MTM.
The WHEN clause in SQL*Loader, despite what you might read, doesn't seem to evaluate the value of the column you specify after SQL clauses are processed. Therefore, the only way you can guarantee to NOT LOAD a record is by using a function to raise an application error when the column data meets your criteria. You'll need to do some basic comparisons between bad data and discarded data in the bad data file to isolate these.
You can still discard the null data using (replace ne with greater and less than)WHEN (g ne '')Hope this helps,
Luke
Please mark the answer as helpful or answered if it is so. If not, provide additional details.
Always try to provide create table and insert table statements to help the forum members help you better. -
How to have more than one condition on same column --- using SQL Loader
Hi All,
I am stuck with SQL Loader..
How do I filter records before loading in the table using when clause..
i should load data only when
field1 = 'AC' or 'VC'
field2 is NULL
i used various combinations in when clause like
a) when field1='AC' or field1='VC' and field2 = BLANKS
b) when (field1='AC') and (field2 = BLANKS )
& similar...
In all the cases I tried I could not implement OR condition with field1 and null condition with field2
but my main concern is can we use OR or IS NULL things in when clause of SQL Loader..
is it possible to check this anywhere??
any alternate solution u could suggest??
Thanks
DikshitOk I'll try that, although I did try it earlier when I had iTunes 5.xx loaded, I think.
As to size of playlists, I have a master (900 songs) that defines what will fit onto the ipod , I then generate all the others as subsets of the master (not of the library)- hence I know they will all fit
Can you also clarify something for me: the dialogue box we are discussing is intended, I think, so that one can set the automatic synching of certain playlists between the PC & the ipod. Is that the only way one can select other playlists to go to the ipod - i.e. as static once-offs, not synchronised ?
Apple' docs, I think, are poor in this regard - they assume most ipods are bigger then the users song library and they gloss over the details of this alternate mode of playlist synching.
Thanks - Nick -
SQL Loader to append data in same table but using differnet WHEN clauses
In my data file i have a header record and a detail record identified by Record_type = 1 and 2 respectively.
The Database table has all the columns to capture detail records but i want to capture jus one column of header record now also in my existing table. So i have added that column (DATA_DATE)in my table but how to capture that value ?
im writing my control file using two WHEN clauses, something like -
load data
into table t_bdn
append
when RECORD_TYPE = '2'
FIELDS TERMINATED BY "|" TRAILING NULLCOLS
SEQUENCE_NO
, RECORD_TYPE
, DISTRIBUTOR_CODE
, SUPPLIER_CODE
, SUPPLIER_DISTRIBUTOR_CODE
, DISTRIBUTOR_SKU
, SUPPLIER_SKU
when RECORD_TYPE = '1'
FIELDS TERMINATED BY "|" TRAILING NULLCOLS
SEQUENCE_NO FILLER
, RECORD_TYPE FILLER
, CREATE_DATE FILLER
, DATA_DATE "NVL(to_date(:DATA_DATE, 'YYYY/MM/DD'),to_date('9999/12/31', 'YYYY/MM/DD'))"
im getting error " expecting INTO and foung WHEN RECORD_TYPE = '1' "
if i give iNTO second time it will append a new row altogether in my table but i want the same row to be updated with this DATA_DATE value coming from RECORD_TYPE =1 and header record has 4 delimited data text fields only and i am interested in fetching just the 4th column..
KIndly suggest what to do ?Ravneek, I could be wrong but sqlldr is a 'load' program, that is, it inserts data. I am unaware of any ability to update existing rows as you seem to want. What you appear to want to do is more the job of a merge statement.
I would look at writing a pro* language, a .net, or a java program to perform inserts where some or all of the newly inserted rows are also to be updated.
From the manual: (Oracle® Database Utilities 10g Release 2 (10.2) Part Number B14215-01)
Updating Existing Rows
The REPLACE method is a table replacement, not a replacement of individual rows. SQL*Loader does not update existing records, even if they have null columns. To update existing rows, use the following procedure:
1. Load your data into a work table.
2. Use the SQL language UPDATE statement with correlated subqueries.
3. Drop the work table.
HTH -- Mark D Powell -- -
Hi,
Please could someone give me the syntax for expressing a where clause in SQL Loader control file? as an example i only want the data in the columns to be uploaded where person_id matches the person_id already present in the table.
My control file is below which needs amending to include a 'Where'. The append will also need changing i assume.
load data
infile '/app/DEV/appl/xxcpp/11.5.0/bin/TEST.csv'
APPEND
into table XXCPP_SQL_LOADER_TEST
fields terminated by "," optionally enclosed by '"'
( PERSON_ID, EMP_NAME, EMP_NUMBER, START_DATE DATE "fmDD/MM/RRRR" )
Many ThanksSQL*Loader has very limited conditional load capabilities. WHEN clause does not support OR (and it is documented). Anyway, you could do the following. Control file:
load data
infile *
APPEND
into table XXCPP_SQL_LOADER_TEST
When Person_id = '1'
fields terminated by "," optionally enclosed by '"'
( PERSON_ID POSITION(1), EMP_NAME, EMP_NUMBER, START_DATE DATE "fmDD/MM/RRRR" )
into table XXCPP_SQL_LOADER_TEST
When Person_id = '2'
fields terminated by "," optionally enclosed by '"'
( PERSON_ID POSITION(1), EMP_NAME, EMP_NUMBER, START_DATE DATE "fmDD/MM/RRRR" )
into table XXCPP_SQL_LOADER_TEST
When Person_id = '3'
fields terminated by "," optionally enclosed by '"'
( PERSON_ID POSITION(1), EMP_NAME, EMP_NUMBER, START_DATE DATE "fmDD/MM/RRRR" )
begindata
1,A,11,13/01/2011
2,B,12,13/01/2011
3,C,13,13/01/2011
4,D,14,13/01/2011
5,D,15,13/01/2011
{code}
Now:
{code}
SQL> select * from XXCPP_SQL_LOADER_TEST;
no rows selected
SQL> host sqlldr scott/tiger control=c:\temp\XXCPP_SQL_LOADER_TEST.CTL log=c:\temp\XXCPP_SQL_LOADER_TEST.LOG
SQL> select * from XXCPP_SQL_LOADER_TEST;
PERSON_ID EMP_NAME EMP_NUMBER START_DAT
1 A 11 13-JAN-11
2 B 12 13-JAN-11
3 C 13 13-JAN-11
SQL>
{code}
SY. -
Sql loader user identification
Hi, there:
Can anyone tell me if I can run sql loader with an extenally identified user so that I don't have to provide a database password for that user when I run sql loader in a batch file? Thanks.
YiInclude the schema name along with the table name as part of the INTO TABLE clause. For example;
INTO TABLE SCOTT.EMP -
CSV FILES DOESN'T LOAD WITH RIGHT DATA USING SQL LOADER
Hi pals, I have the following information in csv file:
MEXICO,Seretide_Q110,2010_SEE_01,Sales Line,OBJECTIVE,MEXICO,Q110,11/01/2010,02/04/2010,Activo,,,MEXICO
MEXICO,Seretide_Q210,2010_SEE_02,Sales Line,OBJECTIVE,MEXICO,Q210,05/04/2010,25/06/2010,Activo,,,MEXICO
When I use SQLLOADER the data is loaded as follow:*
EXICO,Seretide_Q110,2010_SEE_01,Sales Line,OBJECTIVE,MEXICO,Q110,11/01/2010,02/04/2010,Activo,,,MEXICO
And for the next data in a csv file too:
MX_001,MEXICO,ASMA,20105912,Not Verified,General,,RH469364,RH469364,Change Request,,,,,,,Y,MEXICO,RH469364
MX_002,MEXICO,ASMA,30094612,Verified,General,,LCS1405,LCS1405,Change Request,,,,,,,Y,MEXICO,LCS1405
the data is loaded as follow:
X_001,MEXICO,ASMA,20105912,Not Verified,General,,RH469364,RH469364,Change Request,,,,,,,Y,MEXICO,RH469364
X_002,MEXICO,ASMA,30094612,Verified,General,,LCS1405,LCS1405,Change Request,,,,,,,Y,MEXICO,LCS1405
I mean the first character is truncated and this bug happens with all my data. Any suggestion? I really hope you can help me.
Edited by: user11260938 on 11/06/2009 02:17 PM
Edited by: Mariots on 12/06/2009 09:37 AM
Edited by: Mariots on 12/06/2009 09:37 AMYour table and view don't make sense so I created a "dummy" table to match your .ctl file.
SQL> create table CCI_SRC_MX
2 (ORG_BU varchar2(30)
3 ,name varchar2(30)
4 ,src_num varchar2(30)
5 ,src_cd varchar2(30)
6 ,sub_type varchar2(30)
7 ,period_bu varchar2(30)
8 ,period_name varchar2(30)
9 ,prog_start_dt date
10 ,prog_end_dt date
11 ,status_cd varchar2(30)
12 ,X_ACTUALS_CALC_DATE date
13 ,X_ACTUAL_UPDATE_SRC varchar2(30)
14 ,prod_bu varchar2(30)
15 ,ROW_ID NUMBER(15,0)
16 ,IF_ROW_STAT VARCHAR2(90)
17 ,JOB_ID NUMBER(15,0)
18 );
Table created.
SQL> create sequence GSK_GENERAL_SEQ;
Sequence created.I simplified your .ctl file and moved all the constant and sequence stuff to the end. I also changed the format masks to match the dates in your data.
LOAD DATA
INFILE 'SBSLSLT.txt'
BADFILE 'SBSLSLT.bad'
DISCARDFILE 'SBSLSLT.dis'
APPEND
INTO TABLE CCI_SRC_MX
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(ORG_BU
,NAME
,SRC_NUM
,SRC_CD
,SUB_TYPE
,PERIOD_BU
,PERIOD_NAME
,PROG_START_DT DATE 'dd/mm/yyyy'
,PROG_END_DT DATE 'dd/mm/yyyy'
,STATUS_CD
,X_ACTUALS_CALC_DATE DATE 'dd/mm/yyyy'
,X_ACTUAL_UPDATE_SRC
,PROD_BU
,row_id "GSK_GENERAL_SEQ.nextval"
,if_row_stat CONSTANT 'UPLOADED'
,job_id constant 36889106
{code}
When I run SQL Loader, I get this:
{code}
SQL> select * from CCI_SRC_MX;
ORG_BU NAME SRC_NUM SRC_CD SUB_TYPE PERIOD_BU PERIOD_NAME PROG_START_DT PROG_END_DT STATUS_CD PROD_BU ROW_ID IF_ROW_STAT JOB_ID
MEXICO Seretide_Q110 2010_SEE_01 Sales Line OBJECTIVE MEXICO Q110 11-JAN-2010 00:00:00 02-APR-2010 00:00:00 Activo MEXICO 1 UPLOADED 36889106
MEXICO Seretide_Q210 2010_SEE_02 Sales Line OBJECTIVE MEXICO Q210 05-APR-2010 00:00:00 25-JUN-2010 00:00:00 Activo MEXICO 2 UPLOADED 36889106
{code} -
SQL Loader and foreign characters in the data file problem
Hello,
I have run into an issue which I can't find an answer for. When I run SQL Loader, one of my control files is used to get file content (LOBFILE) and one of the fields in the data file has a path to that file. The control file looks like:
LOAD DATA
INFILE 'PLACE_HOLDER.dat'
INTO TABLE iceberg.rpt_document_core APPEND
FIELDS TERMINATED BY ','
doc_core_id "iceberg.seq_rpt_document_core.nextval",
-- created_date POSITION(1) date "yyyy-mm-dd:hh24:mi:ss",
created_date date "yyyy-mm-dd:hh24:mi:ss",
document_size,
hash,
body_format,
is_generic_doc,
is_legacy_doc,
external_filename FILLER char(275) ENCLOSED by '"',
body LOBFILE(external_filename) terminated by EOF
A sample data file looks like:
0,2012-10-22:10:09:35,21,BB51344DD2127002118E286A197ECD4A,text,N,N,"E:\tmp\misc_files\index_testers\foreign\شیمیایی.txt"
0,2012-10-22:10:09:35,17,CF85BE76B1E20704180534E19D363CF8,text,N,N,"E:\tmp\misc_files\index_testers\foreign\ลอบวางระเบิด.txt"
0,2012-10-22:10:09:35,23552,47DB382558D69F170227AA18179FD0F0,binary,N,N,"E:\tmp\misc_files\index_testers\foreign\leesburgis_á_ñ_é_í_ó_ú_¿_¡_ü_99.doc"
0,2012-10-22:10:09:35,17,83FCA0377445B60CE422DE8994900A79,binary,N,N,"E:\tmp\misc_files\index_testers\foreign\làm thế nào bạn làm ngày hôm nay"
The problem is that whan I run this, SQL Loader throws an error that it can't find the file. It appears that it can't interpret the foreign characters in a way that allows it to find that path. I have tried adding a CHARACTERSET (using AL32UTF8 or UTF8) value in the control file but that only has some success with Western languages, not the ones listed above. Also, there is no set of defined languages that could be found in the data file. It essentaially could be any language.
Does anyone know if there is a way to somehow get SQL Loader to "understand" the file system paths when a folder and/or file name could be in some other langauge?
Thanks for any thoughts - PeterThanks for the reply Harry. If I try to open the file in various text editors like Wordpad, Notepad, GVIM, andTextpad, they all display the foreign characters differently. Only Notepad comes close to displaying the characters properly. I have a C# app that will read the file and display the contents and it renders it fine. If you look at the directory of files in Windows Explorer, they all are displayed properly. So it seems things like .Net and Windows have some mechanism to understand the characters in order to render them properly. Other applications, again like Wordpad, do not know how to render them properly. It would seem that whatever SQL Loader is using to "read" the data files also is not rendering the characters properly which prevents it from finding the directory path to the file. If I add "CHARACTERSET AL32UTF8" in the control file, all is fine when dealing with Western langauges (ex, German, Spanish) but not for the Eastern languages (ex. Thai, Chinese). So .... telling SQL Loader to use a characterset seems to work, but not in all cases. The AL32UTF8 is the characterset that the Oracle database was created with. I have not had any luck if I try to set the CHARACTERSET to whatever the Thai character set is, for example. There problem there though is that even if that did work, I can't target specific lagauages because the data could come from anywhere. It's like I need some sort of global "super set" characterset to use. It seems like the CHARACTERSET is the right track to follow but I am not sure, and even if it is, is there a way to handle all languages.
Thanks - Peter -
2 day ago I meet with problem to load text file to Oracle DB with
SQL statment in control file. It's my control file:
LOAD DATA
INFILE '/tmp/123/22-12.txt'
REPLACE
INTO TABLE VL_LOG
(date_time SYSDATE,
SOURCE POSITION(02:16)
"TRUNC(SUBSTR(:SOURCE,1,3))*16777216+TRUNC(SUBSTR(:SOURCE,INSTR(:
SOURCE,'.')+1,3))*65536+TRUNC(SUBSTR(:SOURCE,INSTR(:SOURCE,'.',1,
2)+1,3))*256+RTRIM(SUBSTR(:SOURCE,INSTR(:SOURCE,'.',-1)+1))",
DESTINATION POSITION(19:33)
"TRUNC(SUBSTR(:DESTINATION,1,3))*16777216+TRUNC(SUBSTR(:DESTINATI
ON,INSTR(:DESTINATION,'.')+1,3))*65536+TRUNC(SUBSTR(:DESTINATION,
INSTR(:DESTINATION,'.',1,2)+1,3))*256+SUBSTR(:DESTINATION,INSTR(:
DESTINATION,'.',-1)+1)",
bytes POSITION(54:72) INTEGER EXTERNAL)
When I run SQL Loader with this control file my Linux 5.2
(kernel 2.0.36) say:
Segmentation fault(core dumped).
Later I test this and now may say, that error is only when length
of SQL statment more than 201 bytes(symbols). I think, that input
buffer for this statment to small and loader fault when attempt
to translate incomlete string. I know, that Loader may translate
statments only shorter 258 symbols, and when statment string
greater 258 show error, but not core dumped!
Alex Zykov.
Russia,Tomsk.
null255 is default length. If you need more - specify it exactly as char(2000). You searched wrong forums. I'd suggest you to read manuals instead:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch06.htm#1006961 -
Importing oracle.sql.BLOB through SQL Loader
Hello,
Currently the system we have creates .sql files and executes them. This takes a long time, so we're attempting to change to using SQL Loader. The one problem I'm having that I can't seem to fix is finding out how to imitate the behavior of this SQL statement through SQL Loader:
INSERT INTO KRSB_QRTZ_BLOB_TRIGGERS (BLOB_DATA,TRIGGER_GROUP,TRIGGER_NAME)
VALUES (oracle.sql.BLOB@515263,'KCB-Delivery','PeriodicMessageProcessingTrigger')
I tried creating a lobfile and placing the text oracle.sql.BLOB@515263 within it this way
INTO TABLE KRSB_QRTZ_BLOB_TRIGGERS
WHEN tablename = 'KRSB_QRTZ_BLOB_TRIGGERS'
FIELDS TERMINATED BY ',' ENCLOSED BY '##'
TRAILING NULLCOLS
tablename FILLER POSITION(1),
TRIGGER_NAME CHAR(80),
TRIGGER_GROUP CHAR(80),
ext_fname FILLER,
BLOB_DATA LOBFILE(ext_fname) TERMINATED BY EOF
However, as expected, it merely loaded the text "oracle.sql.BLOB@515263" into the database. So does anyone have any ideas of how to imitate that insert statement through SQL Loader? The only information I have available is the string "oracle.sql.BLOB@515263", no other files or anything to aid with actually getting the binary data.
When the .sql file is run with that insert statement in it, a 1.2kb BLOB is inserted into the database versus a 22 byte BLOB that contains nothing useful when done through SQL Loader.
AlexMy preference is DBMS_LOB.LOADFROMFILE
http://www.morganslibrary.org/reference/dbms_lob.html
did you try it? -
SQL Loader, direct path and indexes on partition tables
Hi,
I have a big partitioned table and I have two indexes on it.
When I use SQL Loader to upload data to my table with using OPTIONS (DIRECT=TRUE) UNRECOVERABLE , then it takes almost half hour to load just one record!!
When I remove OPTIONS (DIRECT=TRUE), then it takes just two seconds to upload the same one record.
Am I missing anything? Can I use direct path load on indexed partitioned tables and have reasonable load time ?
An scheduled external job loads almost 100,000 records into this table every hour and I am trying to make the sql*loader performance it as fast as possible.
Any help would be appreciated,
AlanHi Alan,
How big is this table and what sort of indexes are they?
An index update using SQL*Loader unrecoverable direct path load is achieved by an isolated sort followed by a nologging merge of the old index and the new mini-index into a new index segment (this according to seminar notes by Jonathan Lewis). This will conceivably take a long time for a large table / large index.
Performance improvements? Are you loading all records into a new partition?
Cheers,
Colin -
OWB 10gR2 : How to configure ctl and log locations for Sql*Loader mappings?
Hi all,
I'm using OWB 10gR2 to load data in tables with Sql*Loader mappings.
In my project I have a datafile module and an Oracle module.
When creating an sql*loader mapping in the oracle module, there is two properties for this mappings that I want to modify. The first is Control File Location and the second is Log File Location. Values for those properties are equal to the data file module location. When trying to change those values I can only chose "Use module configuration location".
Somebody knows how to configure those properties with different locations as the one of the flat file module?
What I want to do is to store the data file in one directory, and control file and log file in other directories.
Thank you for your help.
BernardHi,
You're right, my problem is that the dropdown only show the location associated with the flat file location even if I have other file locations created in the design repository.
The good news is that I have found the solution to solve the problem :
1) Edit the file module and in tab "Data locations", add the locations you want to use for control file and log file.
2) Open configuration window of the mapping and then the dropdown for properties Control File Location and Log File Location show new locations
I have tested my mapping after changing those properties and it's working.
Bernard -
SQL Loader Inserting Log File Statistics to a table
Hello.
I'm contemplating how to approach gathering the statistics from the SQL Loader log file to insert them into a table. I've approached this from a Korn Shell Script perspective previously, but now that I'm working in a Windows environment and my peers aren't keen about batch files and scripting I thought I'd attempt to use SQL Loader itself to read the log file and insert one or more records into a table that tracks data uploads. Has anyone created a control file that accomplishes this?
My current environment:
Windows 2003 Server
SQL*Loader: Release 10.2.0.1.0
Thanks,
LukeHello.
Learned a little about inserting into multiple tables with delimited records. Here is my current tested control file:
LOAD DATA
APPEND
INTO TABLE upload_log
WHEN (1:12) = 'SQL*Loader: '
FIELDS TERMINATED BY WHITESPACE
TRAILING NULLCOLS
( upload_log_id RECNUM
, filler_field_0 FILLER
, filler_field_1 FILLER
, filler_field_2 FILLER
, filler_field_3 FILLER
, filler_field_4 FILLER
, filler_field_5 FILLER
, day_of_week
, month
, day_of_month
, time_of_day
, year
, log_started_on "TO_DATE((:month ||' '|| :day_of_month ||' '|| :time_of_day ||' '|| :year), 'Mon DD HH24:MI:SS YYYY')"
INTO TABLE upload_log
WHEN (1:11) = 'Data File: '
FIELDS TERMINATED BY ':'
( upload_log_id RECNUM
, filler_field_0 FILLER POSITION(1)
, input_file_name "TRIM(:input_file_name)"
INTO TABLE upload_log
WHEN (1:6) = 'Table '
FIELDS TERMINATED BY WHITESPACE
( upload_log_id RECNUM
, filler_field_0 FILLER POSITION(1)
, table_name "RTRIM(:table_name, ',')"
INTO TABLE upload_rejects
WHEN (1:7) = 'Record '
FIELDS TERMINATED BY ':'
( upload_rejects_id RECNUM
, record_number POSITION(1) "TO_NUMBER(SUBSTR(:record_number,8,20))"
, reason
INTO TABLE upload_rejects
WHEN (1:4) = 'ORA-'
FIELDS TERMINATED BY ':'
( upload_rejects_id RECNUM
, error_code POSITION(1)
, error_desc
INTO TABLE upload_log
WHEN (1:22) = 'Total logical records '
FIELDS TERMINATED BY WHITESPACE
( upload_log_id RECNUM
, filler_field_0 FILLER POSITION(1)
, filler_field_1 FILLER
, filler_field_2 FILLER
, action "RTRIM(:action, ':')"
, number_of_records
INTO TABLE upload_log
WHEN (1:13) = 'Run began on '
FIELDS TERMINATED BY WHITESPACE
TRAILING NULLCOLS
( upload_log_id RECNUM
, filler_field_0 FILLER POSITION(1)
, filler_field_1 FILLER
, filler_field_2 FILLER
, day_of_week
, month
, day_of_month
, time_of_day
, year
, run_began_on "TO_DATE((:month ||' '|| :day_of_month ||' '|| :time_of_day ||' '|| :year), 'Mon DD HH24:MI:SS YYYY')"
INTO TABLE upload_log
WHEN (1:13) = 'Run ended on '
FIELDS TERMINATED BY WHITESPACE
TRAILING NULLCOLS
( upload_log_id RECNUM
, filler_field_0 FILLER POSITION(1)
, filler_field_1 FILLER
, filler_field_2 FILLER
, day_of_week
, month
, day_of_month
, time_of_day
, year
, run_ended_on "TO_DATE((:month ||' '|| :day_of_month ||' '|| :time_of_day ||' '|| :year), 'Mon DD HH24:MI:SS YYYY')"
INTO TABLE upload_log
WHEN (1:18) = 'Elapsed time was: '
FIELDS TERMINATED BY ':'
( upload_log_id RECNUM
, filler_field_0 FILLER POSITION(1)
, filler_field_1 FILLER
, filler_field_2 FILLER
, elapsed_time
INTO TABLE upload_log
WHEN (1:14) = 'CPU time was: '
FIELDS TERMINATED BY ':'
( upload_log_id RECNUM
, filler_field_0 FILLER POSITION(1)
, filler_field_1 FILLER
, filler_field_2 FILLER
, cpu_time
)Here are the basic table create scripts:
TRUNCATE TABLE upload_log;
DROP TABLE upload_log;
CREATE TABLE upload_log
( upload_log_id INTEGER
, day_of_week VARCHAR2( 3)
, month VARCHAR2( 3)
, day_of_month INTEGER
, time_of_day VARCHAR2( 8)
, year INTEGER
, log_started_on DATE
, input_file_name VARCHAR2(255)
, table_name VARCHAR2( 30)
, action VARCHAR2( 10)
, number_of_records INTEGER
, run_began_on DATE
, run_ended_on DATE
, elapsed_time VARCHAR2( 8)
, cpu_time VARCHAR2( 8)
TRUNCATE TABLE upload_rejects;
DROP TABLE upload_rejects;
CREATE TABLE upload_rejects
( upload_rejects_id INTEGER
, record_number INTEGER
, reason VARCHAR2(255)
, error_code VARCHAR2( 9)
, error_desc VARCHAR2(255)
);Now, if I could only insert a single record to the upload_log table (per table logged); adding separate columns for skipped, read, rejected, discarded quantities. Any advice on how to use SQL Loader to do this (writing a procedure would be fairly simple, but I'd like to perform all of the work in one place if at all possible)?
Thanks,
Luke
Edited by: Luke Mackey on Nov 12, 2009 4:28 PM -
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)
Maybe you are looking for
-
IOP 11.1.2.0 integration with Shared Services (User Provisioning)
In the IOP 11.1.2.0 install guide, the Admin and Admin provisioning roles are provisioned through Shared Services. "Provision Integrated Operational Planning Administrator and Integrated Operational Planning Provisioning Manager roles for the Integra
-
Dublicate the database with one year data
Hi DBA's I need to create the duplicate database instance. But only one year data from the source instance to target instance, source instance is having 3 years data. is it possible to do so? and which method i have to follow to create a Duplicate in
-
Is SQLPlus supported by oracle cloud?
Hi, I'm creating a database system using SQLPlus which will be stored/connected to the cloud. I've been made aware that SQLPlus is not supported by Oracle Cloud and that I should use SQL Developer, is this true or will SQLPlus be supported by Oracle
-
Photoshop Adding Noise to Photos Suddenly
Hi! I am hoping someone can help me with this. I have been using Photoshop for years. Within the past month or so, Photoshop CS6 has been adding noise to my photos after saving. This has never happened before. This is my process: I shoot in raw + jpe
-
OracleCSService unable to start on win2003 node after patching to 10.2.0.4
Hi, Anyone facing problem starting the CS service after patching to 10.2.0.4 on 1 win2003 node while other win2003 node works fine? Well seems I found the solution to it. Pl read on if u r facing same problem: 1. on the non-working node goto the log