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 AM
The 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
Similar Messages
-
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 -
Concatenate positions in control file for sql*loader utility.
Is there a way to concatenate several character positions in a control file for sql*loader???
example... field1 position(1:3) || position(5:7) ????
I would rather not create any unnecessary temp tables for a straight load...How about...
/code
field1 position(1:7) char "substr(:field1, 1, 3) || substr(:field1, 5)" -
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 -
How to pass value from the jsp file to a java bean
I have huge promblem .I want to pass value of combo box to bean file to set my database contecting.The is how i call function to pass database to the bean file
<%db.setDatabase(database);%>are coding to set my databse connection
private String database;
public Conn(){
try{
Class.forName("org.gjt.mm.mysql.Driver");
DriverManager.registerDriver((Driver) Class.forName("org.gjt.mm.mysql.Driver").newInstance());
String data=getDatabase();
String url = "jdbc:mysql://localhost/"+data;
Connection conn = DriverManager.getConnection(url);
setConnection(conn);
catch(SQLException e){
System.out.println(e.toString());
catch(Exception e){
System.out.println(e.toString());
public void setDatabase(String Database){
this.database = Database;
public String getDatabase(){
return this.database;
} and Below are error produce
Note: sun.tools.javac.Main has been deprecated.
/mrs/system_menu.jsp:18: Method setDatabase(java.lang.String) not found
in class bgoc.dbConn.Conn.
db.setDatabase(database);
^
1 error, 1 warning
please help me soon. any that come to your will help
thank youI have huge promblem .I want to pass value of combo box to bean file to set my database contecting.The is how i call function to pass database to the bean file
<%db.setDatabase(database);%>are coding to set my databse connection
private String database;
public Conn(){
try{
Class.forName("org.gjt.mm.mysql.Driver");
DriverManager.registerDriver((Driver) Class.forName("org.gjt.mm.mysql.Driver").newInstance());
String data=getDatabase();
String url = "jdbc:mysql://localhost/"+data;
Connection conn = DriverManager.getConnection(url);
setConnection(conn);
catch(SQLException e){
System.out.println(e.toString());
catch(Exception e){
System.out.println(e.toString());
public void setDatabase(String Database){
this.database = Database;
public String getDatabase(){
return this.database;
} and Below are error produce
Note: sun.tools.javac.Main has been deprecated.
/mrs/system_menu.jsp:18: Method setDatabase(java.lang.String) not found
in class bgoc.dbConn.Conn.
db.setDatabase(database);
^
1 error, 1 warning
please help me soon. any that come to your will help
thank you -
How to pass parameters to the Control file while loading the data from flat file to staging table
Thanks in advance
Hi ,
LOADDATA statement is required at the beginning of the control file.
INFILE: INFILE keyword is used to specify location of the datafile or datafiles.
INFILE* specifies that the data is found in the control file and not in an external file. INFILE ‘$FILE’, can be used to send the filepath and filename as a parameter when registered as a concurrent program.
INFILE ‘/home/vision/kap/import2.csv’ specifies the filepath and the filename.
Hope this will help you...... -
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.
-
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 -
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 -
Control file for SQL*Loader
Hello,
I have the following file (2 line) which I want to intend in an oracle database with the SQL*Loader.
tommy050+3423
tom 070-0006
The file consists of two lines and three columns.
Column1 has always 5 digits and is a String. Additional empty digits will be filled with blanks. Here: tommy and tom
Column2 has three digits and is a number. Here: 050 and 070.
Column 3 is also a number and consists of four digits. Additionally there is a fifth digit for the leading sign ("+" or "-"). Here: +3423 and -0006.
This file I want to import in my table MyTab.
MyTab(
thing VARCHAR2(5)
number NUMBER(3)
amount NUMBER
How would the control file for the SQL*Loader look like for this example?
Regards
HomerThis is a start (untested)
LOAD DATA
INFILE 'sample.dat'
BADFILE 'sample.bad'
DISCARDFILE 'sample.dsc'
APPEND
INTO TABLE MyTab
( thing POSITION(1:5) CHAR ,
NUMBER POSITION(6:8) INTEGER,
amount POSITION(9:12) INTEGER )Can you have a column named number? -
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
KishoreHi,
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 -
How to pass values from single Databank file across different scripts?
Hi Guys,
I have a question regarding using single databank file across different scripts.
Lets say there 5 web service scripts and these are very generic scripts where the input/request xml schema of each script is parameterized without having any databank as script asset.
These 5 web service scripts are like library functions and so we dont want to attach any databank as script asset.
However I have a driver script to call all of these 5 library scripts and now I attach a databank (a .csv file) to the driver script as script asset. Say this .csv file has got 10 different columns with just single record/row.
As and when the function call goes to those 5 scripts i.e one by one, then based on the function call the corresponding columns are used and the data for those columns must be read.
Is there any solution to acheive this?
Faster help is highly appreciated.Hi JB,
what i was looking for, was an approach to use a databank file (.csv file) in a parent script and then by reading that .csv file, the data should be moved from the parent script to individual child scripts.
The child scripts are very generic scripts and are like library functions which are not data dependent. they are fully parameterized and they dont have any sort of databank attached to them.
Now the question is if the databank has got 10 columns where first 3 columns belong to one child script, second 3 columns belong to 2nd child script and so on.
Then how do we pass the values from parent script to a child script and what is the best/recommended approach. -
How to pass values to select clause in PL/SQL procedure
Am relatively new to PL/SQL programming and ran into the following issue...
Table
EMP_MASTER
ID VARCHAR2(10);
FIRSTNAME VARCHAR2(20);
DATA FOR EMP_MASTER
'1','SCOTT'
'2','TIGER'
I ran the following SQL Query
SELECT COUNT(*) FROM EMP_MASTER WHERE FIRSTNAME IN ('SCOTT','TIGER');
This select Query is working fine and we get the count = 2 as
expected. Now I want a procedure for the same fn()
CREATE OR REPLACE PROCEDURE TEST_EMP_MASTER(NAMELIST IN VARCHAR2)
IS
CNT NUMBER := 0;
BEGIN
SELECT COUNT(*) INTO CNT FROM EMP_MASTER WHERE FIRSTNAME IN (NAMELIST);
DBMS_OUTPUT.PUT_LINE('Output-->NAMELIST:'||NAMELIST||':cnt:'||cnt);
END;
Now when I test the procedure by passing just one value its working
fine. But when I want to pass multiple values, it doesnt work!
set serveroutput on;
i.e exec TEST_EMP_MASTER('SCOTT'); Works and the output is
Output--->NAMELIST:SCOTT:cnt:1
but don't get the expected output for exec TEST_EMP_MASTER('SCOTT,TIGER');
I understand that the IN modifier in the WHERE clause expects the
values as 'Value1','value2'....I tried different combination by the
passing the values with quotes '''value1'',''value2'''.....but no
successSelect e.*
From EMP_MASTER e;
ID FIRSTNAME
1 1 SCOTT
2 2 TIGER
3 3 CAT
4 4 MOUSE
SQL> create or replace procedure count_emp_master (p_namelist VARCHAR2)
2 AS
3 v_namelist VARCHAR2 (1000) := p_namelist;
4 v_name Varchar2(100);
5 v_count Number := 0;
6 p_count_emp Number := 0;
7 BEGIN
8 v_namelist := ',' || v_namelist || ',';
9
10 FOR cur IN 1 .. LENGTH (v_namelist) - LENGTH (REPLACE (v_namelist, ',', '')) - 1
11 LOOP
12 v_name := (SUBSTR (v_namelist,
13 INSTR (v_namelist, ',', 1, cur) + 1,
14 INSTR (v_namelist, ',', 1, cur + 1)
15 - INSTR (v_namelist, ',', 1, cur) - 1
16 ));
17 Select Count(1)
18 Into v_count
19 From emp_master
20 Where FIRSTNAME = v_name;
21
22 p_count_emp := p_count_emp + v_count;;
23
24 END LOOP;
25
26 dbms_output.put_line ('namelist --> '||p_namelist ||'p_count_emp -->'||p_count_emp);
27 END count_emp_master;
28 /
Procedure created
SQL> exec count_EMP_MASTER('SCOTT');
namelist --> SCOTTp_count_emp -->1
PL/SQL procedure successfully completed
SQL> exec count_EMP_MASTER('SCOTT,TIGER');
namelist --> SCOTT,TIGERp_count_emp -->2
PL/SQL procedure successfully completed
SQL> exec count_EMP_MASTER('SCOTT,TIGER,CAT');
namelist --> SCOTT,TIGER,CATp_count_emp -->3
PL/SQL procedure successfully completed
SQL> exec count_EMP_MASTER('SCOTT,TIGER,CAT,MOUSE');
namelist --> SCOTT,TIGER,CAT,MOUSEp_count_emp -->4
PL/SQL procedure successfully completed
SQL> Message was edited by:
Nicloei W
Maybe you are looking for
-
I have a new 2012 R2 Domain Controller and Exchange 2013 server running on Server 2012 R2. I have a few Windows XP clients that for some reason as of Monday cannot browse or access the file shares on the Domain Controller. However they can still acce
-
Local Administration rights for Xcelcius and Crystal Reports
Hello Customercare, I am currently compiling a list of software that does and does not require local administrator rights to install and run. I was wondering if you would be able to assist me, we currently use Crystal Reports version 8.5 and Cr
-
I want data from the Address Book to appear on a series of Pages envelopes. Help says to "Insert > Sender or Insert > Merge" but (no surprise here) gives no hint at what the difference is. Why would I pick one or the other?
-
hi all, can anybody tell me if you can change the font size on the e65 and if so how? thanxMessage Edited by jp47 on 19-Mar-2007 08:56 PM
-
"Delivered without sales Order Number"
Hi Geeks Can anybody let me know the steps to solve the error "Delivered without sales Order Number"? thanks®ards dj reddy