Substitution for logical OR usage in control file of sql loader
Hi,
can anyone suggest me a substituion method to use the functionality of logical OR in control file developed for sql loader.
Ex:
load data
append
into table ABC
when (1:2) = 'AD'
--AND ((27:28)= '01' OR (27:28)= '02')
AND (1222:1222) = '1'
trailing nullcols
Note: condition commented in the above example need to be replaced.
one way of doing it can be splitting blocks for each condition.
Then it will look like:
load data
append
into table ABC
when (1:2) = 'AD'
AND (27:28)= '01'
AND (1222:1222) = '1'
trailing nullcols
into table ABC
when (1:2) = 'AD'
AND (27:28)= '02'
AND (1222:1222) = '1'
trailing nullcols
So, i'm looking for a better way than this, as i cannot work with the above
splitting logic because i'm dealing with lot many conditions.
Thanx inadvance
Kishore
Hi,
can anyone suggest me a substituion method to use the functionality of logical OR in control file developed for sql loader.
Ex:
load data
append
into table ABC
when (1:2) = 'AD'
--AND ((27:28)= '01' OR (27:28)= '02')
AND (1222:1222) = '1'
trailing nullcols
Note: condition commented in the above example need to be replaced.
one way of doing it can be splitting blocks for each condition.
Then it will look like:
load data
append
into table ABC
when (1:2) = 'AD'
AND (27:28)= '01'
AND (1222:1222) = '1'
trailing nullcols
into table ABC
when (1:2) = 'AD'
AND (27:28)= '02'
AND (1222:1222) = '1'
trailing nullcols
So, i'm looking for a better way than this, as i cannot work with the above
splitting logic because i'm dealing with lot many conditions.
Thanx inadvance
Kishore
Similar Messages
-
Can I have two Data Files in One control file of sql*loader tool
hi,
Can someone help me out. is it possible to have two Data Files in one control file of Sql*loader.
And isit possible to run 10,000 records before lunch and 10,000 records before tea and 10,000 records before evening session by giving breaks after every 10,000 records.
Thanks
RamYes. You can specify two datafiles in one control file and can load using sql loader.
I give you the sample control file.
Load DATA
INFILE 'TEST1.CSV'
INFILE 'TEST2.CSV'
TRUNCATE
INTO TABLE TEST_P
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(COL_1,
COL_2,
COL_n)
Hope It will help you.
-Karthik -
How do i map one field to another in control file via SQL Loader
Can someone please reply back to this question
Hi,
I have a flat file (student.dat delimiter %~| ) using control file (student.ctl) through sql loader. Here are the details.
student.dat
student_id, student_firstname, gender, student_lastName, student_newId
101%~|abc%~|F %~|xyz%~|110%~|
Corresponding table
Student (
Student_ID,
Student_FN,
Gender,
Student_LN
Question:
How do i map student_newId field to student_id field in STUDENT DB table so that new id should be inserted in student_id column. How do i specify the mapping in control file. I dont want to create a new column in student table. Please let me know the best way to do this.
Can someone please reply back to this question.
My approach:
In control file i will sepecify the below, Is this a best approach?. Do we have any othe way?
STUDENT_ID *(:STUDENT_NEWID)*,
STUDENT_FN,
GENDER,
STUDENT_LNAME,
STUDENT_NEWID BOUNDFILLER
Thanks
Sunil
Edited by: 993112 on Mar 13, 2013 12:28 AM
Edited by: 993112 on Mar 13, 2013 12:30 AM
Edited by: 993112 on Mar 13, 2013 12:31 AM
Edited by: 993112 on Mar 18, 2013 2:52 AMOK, ok...
Here is the sample data:
101%~|abc%~|F %~|xyz%~|110%~|
102%~|def%~|M %~|pqr%~|120%~|
103%~|ghi%~|M %~|stu%~|130%~|
104%~|jkl%~|F %~|vwx%~|140%~|
105%~|mno%~|F %~|yza%~|150%~|Here is the control file:
LOAD DATA
INFILE student.dat
TRUNCATE INTO TABLE STUDENT
FIELDS TERMINATED BY '%~|' TRAILING NULLCOLS
student_old FILLER
, student_fn
, gender
, student_ln
, student_id
)And here is the execution:
SQL> CREATE TABLE student
2 (
3 student_id NUMBER
4 , student_fn VARCHAR2 (10)
5 , gender VARCHAR2 (2)
6 , student_ln VARCHAR2 (10)
7 );
Table created.
SQL>
SQL> !sqlldr / control=student.ctl
SQL*Loader: Release 11.2.0.3.0 - Production on Tue Mar 19 14:37:31 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 5
SQL> select * from student;
STUDENT_ID STUDENT_FN GENDER STUDENT_LN
110 abc F xyz
120 def M pqr
130 ghi M stu
140 jkl F vwx
150 mno F yza
SQL>:p -
Pass parameter to control file in SQL LOADER
Hi guys,
I need your help.
I'm currently using Linux Enterprise 3.0 and ORACLE database.
I got many ASCII text files in a folder.
And I want to load those text files to database during interval of time.
For example, if in that folders contains 10 text files I'll load one by one until no file in the folder in once time.
What i want is Firstly, i got the name of 10 files then i scan one by one pass its name to control files and start loading.
After that I do with the second file by follow the first step until reach the 10th file.
can anyone help?
TIA
luxSomething like
for file in <<my_directory>>
do
sqlldr userid=<<my_connectstring>> data=$file control=<<my_controlfile.ctl>>
donehttp://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch04.htm#1004744 -
How do I skip footer records in Data file through control file of sql*loade
hi,
I am using sql*loader to load data from data file and i have written control file for it. How do i skip last '5' records of data file or the footer records to be skiped to read.
For first '5' records to be skiped we can use "skip" to achieve it but how do i acheive for last '5' records.
2)
Can I mention two data files in one control file if so what is the syntax(like we give INFILE Where we mention the path of data file can i mention two data file in same control file)
3)
If i have datafile with variable length (ie 1st record with 200 charcter, 2nd with 150 character and 3rd with 180 character) then how do i load data into table, i mean what will be the syntax for it in control file.
4)if i want to insert sysdate into table through control file how do i do it.
5) If i have variable length records in data file and i have first name then white space between then and then last name, how do i insert this value which includes first name and last name into single column of the table.( i mean how do you handle the white space in between first name and last name in data file)
Thanks in advance
ramYou should read the documentation about SQL*Loader.
-
Different log file name in the Control file of SQL Loader
Dear all,
I get every day 3 log files with ftp from a Solaris Server to a Windows 2000 Server machine. In this Windows machine, we have an Oracle Database 9.2. These log files are in the following format: in<date>.log i.e. in20070429.log.
I would like to load this log file's data to an Oracle table every day and I would like to use SQL Loader for this job.
The problem is that the log file name is different every day.
How can I give this variable log file name in the Control file, which is used for the SQL Loader?
file.ctl
LOAD DATA
INFILE 'D:\gbal\in<date>.log'
APPEND INTO TABLE CHAT_SL
FIELDS TERMINATED BY WHITESPACE
TRAILING NULLCOLS
(SL1 DATE "Mon DD, YYYY HH:MI:SS FF3AM",
SL2 char,
SL3 DATE "Mon DD, YYYY HH:MI:SS FF3AM",
SL4 char,
SL5 char,
SL6 char,
SL7 char,
SL8 char,
SL9 char,
SL10 char,
SL11 char,
SL12 char,
SL13 char,
SL14 char,
SL15 char)
Do you have any better idea about this issue?
I thought of renaming the log file to an instant name, such as in.log, but how can I distinguish the desired log file, from the other two?
Thank you very much in advance.
Giorgos BaliotisI don't have a direct solution for your problem.
However if you invoke the SQL loader from an Oracle stored procedure, it is possible to dynamically set control\log file.
# Grant previleges to the user to execute command prompt statements
BEGIN
dbms_java.grant_permission('bc4186ol','java.io.FilePermission','C:\windows\system32\cmd.exe','execute');
END;
* Procedure to execute Operating system commands using PL\SQL(Oracle script making use of Java packages
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
import java.io.*;
public class Host {
public static void executeCommand(String command) {
try {
String[] finalCommand;
finalCommand = new String[4];
finalCommand[0] = "C:\\windows\\system32\\cmd.exe";
finalCommand[1] = "/y";
finalCommand[2] = "/c";
finalCommand[3] = command;
final Process pr = Runtime.getRuntime().exec(finalCommand);
new Thread(new Runnable() {
public void run() {
try {
BufferedReader br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String buff = null;
while ((buff = br_in.readLine()) != null) {
System.out.println("Process out :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
catch (IOException ioe) {
System.out.println("Exception caught printing process output.");
ioe.printStackTrace();
}).start();
new Thread(new Runnable() {
public void run() {
try {
BufferedReader br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String buff = null;
while ((buff = br_err.readLine()) != null) {
System.out.println("Process err :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
catch (IOException ioe) {
System.out.println("Exception caught printing process error.");
ioe.printStackTrace();
}).start();
catch (Exception ex) {
System.out.println(ex.getLocalizedMessage());
public static boolean isWindows() {
if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
return true;
else
return false;
* Oracle wrapper to call the above procedure
CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
AS LANGUAGE JAVA
NAME 'Host.executeCommand (java.lang.String)';
* Now invoke the procedure with an operating system command(Execyte SQL-loader)
* The execution of script would ensure the Prod mapping data file is loaded to PROD_5005_710_MAP table
* Change the control\log\discard\bad files as apropriate
BEGIN
Host_Command (p_command => 'sqlldr system/tiburon@orcl control=C:\anupama\emp_join'||1||'.ctl log=C:\anupama\ond_lists.log');
END;Does that help you?
Regards,
Bhagat -
Control file to sql*loader
Hi,
i'm doing my project work in the data base mangement and i'm not understanding the control file for the sql*loader and how it works...so, anyone please help me by explaining the topic and by sending a sample code...
thanks.Something like
for file in <<my_directory>>
do
sqlldr userid=<<my_connectstring>> data=$file control=<<my_controlfile.ctl>>
donehttp://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch04.htm#1004744 -
Role of "str ' EORD \r\n'" value in control file in sql loader
Hi All,
Could any one please let me know what is the exact use of "str '<EORD>\r\n'" statement in control file ?, while populating data from .dat file into database table.
When I am trying with this option, I am able to load a single record into a database table. If I remove this statement form control file, complete records from file get populated into table. I am using Linux server for imp data with sqlloader.
Also, Does there any difference to use this statement in control file on Linux server and on AIX server ?
Here is the structure of my ctl file.
load data
infile 'data/EZMAIL/CDSWEB.EZMAIL.dat'
*"str '<EORD>\r\n'"*
into table CDSWEB.EZMAIL
fields terminated by '#<EOFD>#'
trailing nullcols (
Thanks
PravinHi Harry,
Thanks for suggestion, I tried with "str '\n'" instead of "str '<EORD>\r\n'" in control file and it worked properly.
But I am still confuse, Does it really a Linux issue ? as this doesn't work on Linux and the same work on AIX.
This is a sample record form .dat file which I am trying to load into database table.
100#<EOFD>#12#<EOFD>#0#<EOFD>##<EOFD>#2nd Year Term Letter#<EOFD>#80#<EOFD>#2000-01-05-05.00.00.000000#<EOFD>#1#<EOFD>#80#<EOFD>#IMAGE.dat.002.lob#<EOFD>#100#<EOFD>#1#<EOFD>#2nd Year Term Renewal Letter.JPG#<EOFD>#0#<EOFD>#image/pjpeg#<EOFD>##<EOFD>#1#<EOFD>#0#<EOFD>##<EOFD>#100#<EOFD>#100#<EOFD>##<EOFD>#<EORD>
Thanks,
Pravin -
How to pass value to a control file in sql loader
Hello
please want to know if i can pass a value to a control file?
I have a table which i will populate using a control file but there is a field in the table which i will pass the date of the file.
how can i archive this
Thanks
Edited by: kama021 on Apr 18, 2012 3:49 AMThe content of the control file must be made dynamically to include desired value.
Handle: kama021
Status Level: Newbie
Registered: Jun 9, 2009
Total Posts: 154
Total Questions: 42 (25 unresolved)
Why so many unanswered questions?
Edited by: sb92075 on Apr 18, 2012 6:34 AM -
Not loading from flat file using SQL*Loader
Hi,
I am trying to load from an excel file.
first i converted excel file into csv file and save it as as dat file.
in the excel file one column is salary and the data is like $100,000
while converting xls to csv the salary is changed to "$100,000 " (with quotes and a space after the amount)
after the last digit it will put a space.
in the control file of sql*loader i had given
salary "to_number('L999,999')"
my problem is the space after the salary in the dat file.---> "$100,000 "
what changes i have to make in the to_number function which is in the control file.
Please guide me.
Thanks & Regards
Salih KM
Message was edited by:
kmsalihThanks a lot Jens Petersen
It's is loading ..........
MI means miniute.
am i correct.
but i didn't get the logic behind that.
can u please explain that.
Thanks & Regards
Salih KM -
Unknown issue while loading .dbf file by sql loader
Hi guys,
I am having a unknown issue while loading .dbf file by sql loader.
I need to load .dbf data into oracle table.for this I converted .dbf file by just changing its extension as .csv . file structure after changing .dbf to .csv --
C_N_NUMBER,COMP_CODE,CPT_CODE,C_N_AMT,CM_NUMBER
1810/4,LKM,30,45,683196
1810/5,LKM,30,45,683197
1810/6,LKM,30,45,683198
1810/7,LKM,30,135,683200
1810/8,LKM,30,90,683201
1810/9,LKM,1,45,683246
1810/9,LKM,2,90,683246
1810/10,LKF,1,90,683286
2810/13,LKJ,1,50.5,680313
2810/14,LKJ,1,50,680316
1910/1,LKQ,1,90,680344
3910/2,LKF,1,238.12,680368
3910/3,LKF,1,45,680382
3910/4,LKF,1,45,680395
7910/5,LKS,1,45,680397
7910/6,LKS,1,90,680400
7910/7,LKS,1,45,680401
7910/8,LKS,1,238.12,680414
7910/9,LKS,1,193.12,680415
7910/10,LKS,1,45,680490
then I am loading it by sql loader.but I am getting always error below ...
Record 1: Rejected - Error on table C_N_DETL_TAB, column CPT_CODE.
ORA-01438: value larger than specified precision allowed for this column
Record 2: Rejected - Error on table C_N_DETL_TAB, column CPT_CODE.
ORA-01438: value larger than specified precision allowed for this column
table structure-
create table C_N_DETL_tab
"C_N_NUMBER" VARCHAR2(13),
"COMP_CODE" VARCHAR2(3),
"CPT_CODE" NUMBER(4),
"C_N_AMT" NUMBER(20,18),
"CM_NUMBER" NUMBER(7)
control file-
options(skip=1)
load data
infile '/softdump/pc/C_N_DETL.csv'
badfile '/softdump/pc/C_N_DETL.bad'
discardfile '/softdump/pc/C_N_DETL.dsc'
into table C_N_DETL_tab
truncate
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
C_N_NUMBER CHAR,
COMP_CODE CHAR,
CPT_CODE INTEGER,
C_N_AMT INTEGER,
CM_NUMBER INTEGER
but guys when I am increasing size of all columns of tabel upto its max value then data is loaded but when I am checking column max length after data loaded then its very less..
changed table structure-
create table C_N_DETL_tab
"C_N_NUMBER" VARCHAR2(130),
"COMP_CODE" VARCHAR2(30),
"CPT_CODE" NUMBER(32), ---- max value of number
"C_N_AMT" NUMBER(32,18), ---- max value of number
"CM_NUMBER" NUMBER(32) ---- max value of number
now i ma running ...
sqlldr express/express control=C_N_DETL.ctl log=C_N_DETL.log
o/p-
Table C_N_DETL_TAB, loaded from every logical record.
Insert option in effect for this table: TRUNCATE
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
---------- ---- ---- C_N_NUMBER FIRST * , O(") CHARACTER
COMP_CODE NEXT * , O(") CHARACTER
CPT_CODE NEXT 4 INTEGER
C_N_AMT NEXT 4 INTEGER
CM_NUMBER NEXT 4 INTEGER
Table C_N_DETL_TAB:
20 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
select max(length( CPT_CODE))from C_N_DETL_tab ---> 9
can u tell me why I need to increase size of table columns upto max value?although length of data is soo much less.
kindly check it..thnx in advance...
rgds,
pcNo database version of course. Unimportant.
If I recall correctly, it is 'integer external ' and you would best double quoting the alphanumerics (which you didn't ).
Try changing integer in integer external in the ctl file.
Sybrand Bakker
Senior Oracle DBA -
Problem loading XML-file using SQL*Loader
Hello,
I'm using 9.2 and tryin to load a XML-file using SQL*Loader.
Loader control-file:
LOAD DATA
INFILE *
INTO TABLE BATCH_TABLE TRUNCATE
FIELDS TERMINATED BY ','
FILENAME char(255),
XML_DATA LOBFILE (FILENAME) TERMINATED BY EOF
BEGINDATA
data.xml
The BATCH_TABLE is created as:
CREATE TABLE BATCH_TABLE (
FILENAME VARCHAR2 (50),
XML_DATA SYS.XMLTYPE ) ;
And the data.xml contains the following lines:
<?xml version="2.0" encoding="UTF-8"?>
<!DOCTYPE databatch SYSTEM "databatch.dtd">
<batch>
<record>
<data>
<type>10</type>
</data>
</record>
<record>
<data>
<type>20</type>
</data>
</record>
</batch>
However, the sqlldr gives me an error:
Record 1: Rejected - Error on table BATCH_TABLE, column XML_DATA.
ORA-21700: object does not exist or is marked for delete
ORA-06512: at "SYS.XMLTYPE", line 0
ORA-06512: at line 1
If I remove the first two lines
"<?xml version="2.0" encoding="UTF-8"?>"
and
"<!DOCTYPE databatch SYSTEM "databatch.dtd">"
from data.xml everything works, and the contentents of data.xml are loaded into the table.
Any idea what I'm missing here? Likely the problem is with special characters.
Thanks in advance,I'm able to load your file just by removing the second line <!DOCTYPE databatch SYSTEM "databatch.dtd">. I dont have your dtd file, so skipped that line. Can you check if it's problem with ur DTD?
-
Upload Multiple files in SQL * Loader in one session
Dear all,
I want to upload multiple files using SQL*Loader in one go. In Unix its very easy as I have a quite experience of that. Could any body tell what is a way in Windows to upload multiple files in one go while using SQL * Loader. I want to run that using DOS's Batch file.
Thanks
GhulamIn Unix its very easy like we are putting $ sign.
sqlldr userid=?????/?????
control="/u12/cad_delta.ctl",log="/u12/full_extract/$1",data="/u12/$1",bad="/u12//full_extract/$1",errors=500,silent=feedback
Suggest for Windows? It should read all .DAT files of the Windows Folder.
Thanks -
Loading multiple files with SQL Loader
Hello.
I will appreciate your recommendation about the way to load multiple files (to multiple tables) using SQL Loader with only one Control file.
file1 to load to Table1, file2 to load to Table2 etc.
How the Control file should look like?
I was looking on Web, but didn't find exactly what I need.
Thanks!Ctl File : myctl.ctl
---------- Start ---------
LOAD DATA
INFILE 'F:\sqlldr\abc1.dat'
INFILE 'F:\sqlldr\abc2.dat'
INTO TABLE hdfc1
(TRANS_DATE CHAR,
NARRATION CHAR,
VALUE_DATE CHAR,
DEBIT_AMOUNT INTEGER,
CREDIT_AMOUNT INTEGER,
CHQ_REF_NUMBER CHAR,
CLOSING_BALANCE CHAR)
INTO TABLE hdfc2
(TRANS_DATE CHAR,
NARRATION CHAR,
VALUE_DATE CHAR,
DEBIT_AMOUNT INTEGER,
CREDIT_AMOUNT INTEGER,
CHQ_REF_NUMBER CHAR,
CLOSING_BALANCE CHAR)
-----------End-----------
Sqlldr Command
sqlldr scott/tiger@dbtalk control=F:\sqlldr\myctl.ctl log=F:\sqlldr\ddl_file1.txt
Regards,
Abu -
Problem with loading file with SQL loader
i am getting a problem with loading a file with SQL loader. The loading is getting
terminated after around 2000 rows whereas there are around 2700000 rows in the file.
The file is like
919879086475,11/17/2004,11/20/2004
919879698625,11/17/2004,11/17/2004
919879698628,11/17/2004,11/17/2004
the control file, i am using is like:-
load data
infile 'c:\ran\temp\pps_fc.txt'
into table bm_05oct06
fields terminated by ","
(mobile_no, fcal, frdate )
I hope, my question is clear. Please help, in solving the doubt.
regards.So which thread is telling the truth?
Doubt with SQL loader file wih spaces
Are the fields delimited with spaces or with commas?
Perhaps they are a mixture of delimiters and that is where the error is coming in?
Maybe you are looking for
-
My iPhone 5 dice play broken so I want to replace my iPhone 5 by apple
My iPhone 5 scrin damage so I want to replace my Iphone 5 in under warenty
-
Which table to be refered to get shipping document (VT01N) number created w
Which table to be refered to get shipping document (VT01N) number created with reference to Inbound delivery (VL31N).
-
Problem running Sample ADF UI Shell Template
Hi All, Jdev : 11.1.1.6.0 OS : Windows 7 I am trying to run, test and learn ADF UI shell template.In this regard, I have downloaded the sample from the link below of Oracle Magazine and get the error below. I have successfully installed the schema [h
-
Marking unmarking problem with nokia 5230.
Recently most of the college studends having Nokia 5230 or 5233 mobiles. In this mobile, while marking unmarking, all time we have to go to option and select mark unmark. so please update software for this issue.
-
On an iPod 5 how do you get it to show your battery percentage
I saw on my friends iPhone 5 that it showed the percentage of battery at the top.. How do you do that in settings on an iPod 5?