Script for sql*loader
Hi All,
I am loading the data from .csv format to table by using sql*loader.
This sql*loader command was existed in one of the pl/sql Procedure. this procedure will first create a table and then it will get the data by using sql*loader command,then one procedure will run.
to run this script we are manually loading the data from excel by using sql*laoder by running the .ctl command from Command prompt.. instead of doing manually this process is there any other way to do it automatically.
if it is possible please let me know.
here i am giving the script
drop table emp;
create table emp
(eno number,
ename varchar2(20),
job varchar2(20),
sal number(4),
doj date
- here table created.then here by using below sql*loader command loading the data info emp table
load data
infile <file path>
fields terminated by ','
intto table emp
(eno,
ename,
job,
sal)by running this control file manually from command prompt loading the data.
then there is a procedure which we need to to update the EMP table.
for this whole thing we are just running the script except loading the data part.
for this please let me know the automation part.
Thanks.
Hi,
Create a shell Script(Unix) or Windows batch Job to automate the entire process. The script will like below
1.Connect SQLPLUS with the Createtable.SQL file (The Createtable.sql will have the create table script)
2.invoke sql loader with the control file
3.then again connect SQLPLUS with the executeproc.sql file (the executeproc.sql will have the execute command to execute the stored procedure)
by this way your entire process can be in one script and automate by scheduling it in unix or windows.
Thanks,
Vijay
Edited by: Vijayaraghavan Krishnan on Nov 27, 2012 4:48 PM
Similar Messages
-
How to set default directory for SQL LOADER
hi all,
i wanted to know how can we setup a default directory for SQL LOADER if at all we can. i connot place my control and data files in local system and use them at command prompt. rather i wanted to know if we can set default directory that the loader can use. this requirement is basically to enable all the clients to upload the data placed on the server and use the loader utility.
thanks in advance,
BasavrajElla,
You don't say which version of SQL Developer you are using via Citrix, but just setting the SQLDEVELOPER_USER_DIR hasn't worked for a long time (see Re: SQLDEVELOPER_USER_DIR does not function anymore). Also, since version 1.5, the default for the user directory (now set via ide.user.dir as shown below) is under the user profile area (relative to %APPDATA%), which you should be able to write to, even on Citrix.
Assuming that neither of those help, you will need to get whoever installed SQL Developer on the Citrix C: drive to modify the sqldeveloper.conf to have a line like, where the path exists for everyone who will be using the shared SQL Developer (assumes everyone has a H: drive):
AddVMOption -Dide.user.dir=H:\sqldeveloperAn alternative (depending on how you start SQL Developer via Citrix), is to create your own shortcut to start SQL Developer with something like:
sqldeveloper -J-Dide.user.dir="%SQLDEVELOPER_USER_DIR%"theFurryOne -
Format input for Sql*Loader
I have a problem in formating an input file for Sql*Loader
The file has the following format:
1 Jeff
2 Kyle
3 Tom
1 Lisa
2 Bryan
3 Max
4 Rob
5 Steve
1 Richard
2 Mary
and so on
the file should look as follows to process with Sql*Loader:
1 Jeff 2 Kyle 3 Tom
1 Lisa 2 Bryan 3 Max 4 Rob 5 Steve
1 Richard 2 Mary
any suggestions?
Edited by: royce on Sep 18, 2008 2:08 AMroyce wrote:
I have a problem in formating an input file for Sql*Loader
The file has the following format:
1 Jeff
2 Kyle
3 Tom
1 Lisa
2 Bryan
3 Max
4 Rob
5 Steve
1 Richard
2 Mary
and so on
the file should look as follows to process with Sql*Loader:
1 Jeff 2 Kyle 3 Tom
1 Lisa 2 Bryan 3 Max 4 Rob 5 Steve
1 Richard 2 Mary
any suggestions?
Edited by: royce on Sep 18, 2008 2:08 AMActually, looking at your data again, you don't have a consistent format, so this makes it really difficult for something like SQL*Loader to process. If there were just e.g. 3 rows per record then that would be simple, but you are expecting SQL*Loader to look ahead to determine if there is more data or if it's reached the end of the record.
You would be better to load the data (external tables would probably make it quicker and easier as the data will come in the order as it is specified in the file, which would help as you have no group identifier against the sets of records) as it is and then use SQL to process them.
You haven't specified the resulting table that the data is loaded into. Is that just one single VARCHAR column with all the data concatenated or is it several columns (one for each name)? -
Pls give some shell scripting for sql/plsql
pls give some shell scripting for sql/plsql
794244 wrote:
pls give some shell scripting for sql/plsqlNeither SQL or PL/SQL are shell script languages. Both are server side languages that executes inside an Oracle database server process.
This is an important concept to understand when using SQL*Plus for example to "script" interaction with an Oracle database. -
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)" -
Why no exclusive lock for conventional path loading for SQL*Loader?
why no exclusive lock for conventional path loading for SQL*Loader?
it use insert statement so it should use exclusive lock right?
thanksok, so only update statement would put a lock but not for insert statement?
because I have seen a situation where a user update rows in a sesssion (without commit) prevent another user update the rows.
thanks -
Changing the File path for SQL Loader Recognition
I am learning how to create a control file. The names.ctl file was placed in "Names" folder in my "C:\Windows" file.
I get the following error when trying to run the script for sqlldr:
Sql*Loader-500 Unable to open file.
Sql*Loader-553 file not found
Sql*Loader-System error: the system cannot find the specified file.
The path on the folder in c:\Windows\names\names.ctl
How do I make SQL Loader recognize it?Pl post details of OS and database versions. Have you tried this ?
sqlldr CONTROL=c:\Windows\names\names.ctl ...HTH
Srini -
One script for multiple loaded movie clips
Hello,
I am sure that this has been asked or answered before, but
could not locate the correct response.
Problem:
There are 20 movie clips loaded onto the stage through
actionscript. I have 20 different onPress scripts to start the drag
for each (which also contain custom variable).
Problem, I have one single onRelease script which is to be
used for each, but do now wish to give 20 custom handled scripts.
Can I somehow use certain scripting for using one single
generic script for the onRelease? So no matter what was released it
will go through this one script.
Thanks
Dlike this...
activate
set the_folder to choose folder with prompt "Select the folder you want to add folders to..."
tell application "Finder"
set the_name to "Name"
set the_count to 3
repeat with this_num from 1 to the_count
set new_num to this_num as string
if (count new_num) is 1 then set new_num to "0" & new_num
make new folder at the_folder with properties {name:the_name & " " & new_num}
end repeat
end tell -
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? -
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 -
Looking for SQL*Loader sample file
Hi all,
I'm looking for a sample SQL*Loader file that I could use to populate the Bank Statement Interface in Cash Management (Receivables Lockbox Receipts) - specifically CE_STATEMENT_HEADERS_INT_ALL and CE_STATEMENT_LINES_INTERFACE.
I'm trying to put together an interface from Bank of America's Lockbox into our Oracle Receivables system (11.0.3), and don't have access to anything from which to start from.
Thanks in Advance,
Camcheck it
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch10.htm#1656
kuljeet pal singh -
Question for SQL Loader / IMP /EXPORT
hi all,
i just describe my example first : -
TABLE A have five columns.
a_column,b_column,c_column,d_column,e_column.
and have 1000 records.
i want to remove c_column & e_column and add f_column.
on TABLE A. which method (SQL Loader or IMP/EXP) is good suggestion for export & import data before take above action.
borisExport/Import is the most appropiate solution for the task that you want to carry out because SQL*Loader is designed to load data into the database from flat files.
Regarding how to drop the two columns , you can do it
directly if you are working in 9i setting both columns as
unused after drop unused columns in the table.
Complete reference for those utilities:
http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96652.pdf
Joel P�rez -
Shell scripting for sql queires
Hi All,
I have written 4 sql queires.now i want to write shell scripting for this.so please guide me in this issue..
1. select * from emp;
2. select * from dept;
3. delete from emp;
4. delete from dept;
Thank you.Hi,
Apologees for the c!=k!=b stuff. I guess it was to cryptic. It means
C shell is not equal to Korne shell and both are not equal to Bourne shell.
I can't provide you with any site for such stuff. Maybe Google might help? Or someone who is a nicer guy than me... -
Controller file for SQL Loader
Guys,
My data is coming in flat from some third party in the below format
1,Stewart,"Current Address: Street-A, Flat-507, London, UK
Permanent Address: Street-B, Flat-201, London, UK"
2,Patrick,"Current Address: Street-A, Flat-507, Bangalore, India
Permanent Address: Street-B, Flat-201, Delhi, India"
I want to load the data in a custom table by using a SQL loader program which will use a controller program. This program needs to populate the table in below manner
SEQ EMPLOYEE ADDRESS INFORMATION
1 Stewart Current Address: Street-A, Flat-507, London, UK
Permanent Address: Street-B, Flat-201, London, UK
2 Patrick Current Address: Street-A, Flat-507, Bangalore, India
Permanent Address: Street-B, Flat-201, Delhi, India
Could you guys please help me in writing the controller file to read the data from file and populate the table as described above. Thanks.
-SunilIt is a little hard to tell exactly what your data file looks like and what you want your results to be, due to this forum mangling things a bit and adding extra lines and such. In general you can either use CONTINUEIF or CONCATENATE. I have demonstrated both below. When using CONTINUEIF, it assumes each additional line begins with the word "Permanent". When using CONCATENATE, it assumes each two lines constitutes one record. I have also used REPLACE to add a line feed in front of "Permanent", after it is removed during continuation or concatenation.
SCOTT@orcl12c> host type test.dat
1,Stewart,"Current Address: Street-A, Flat-507, London, UK
Permanent Address: Street-B, Flat-201, London, UK"
2,Patrick,"Current Address: Street-A, Flat-507, Bangalore, India
Permanent Address: Street-B, Flat-201, Delhi, India"
SCOTT@orcl12c> host type test.ctl
load data
infile test.dat
continueif next preserve (1:9) = 'Permanent'
into table test_tab
fields terminated by ','
optionally enclosed by '"'
trailing nullcols
(seq, employee,
address_information "replace (:address_information, 'Permanent', CHR(10) || 'Permanent')")
SCOTT@orcl12c> host type test2.ctl
load data
infile test.dat
concatenate 2
into table test_tab
fields terminated by ','
optionally enclosed by '"'
trailing nullcols
(seq, employee,
address_information "replace (:address_information, 'Permanent', CHR(10) || 'Permanent')")
SCOTT@orcl12c> create table test_tab
2 (seq number,
3 employee varchar2(8),
4 address_information varchar2(200))
5 /
Table created.
SCOTT@orcl12c> host sqlldr scott/tiger control=test.ctl log=test.log
SQL*Loader: Release 12.1.0.1.0 - Production on Mon Dec 16 13:11:40 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Path used: Conventional
Commit point reached - logical record count 1
Commit point reached - logical record count 2
Table TEST_TAB:
2 Rows successfully loaded.
Check the log file:
test.log
for more information about the load.
SCOTT@orcl12c> column address_information format a60
SCOTT@orcl12c> select * from test_tab
2 /
SEQ EMPLOYEE ADDRESS_INFORMATION
1 Stewart Current Address: Street-A, Flat-507, London, UK
Permanent Address: Street-B, Flat-201, London, UK
2 Patrick Current Address: Street-A, Flat-507, Bangalore, India
Permanent Address: Street-B, Flat-201, Delhi, India
2 rows selected.
SCOTT@orcl12c> truncate table test_tab
2 /
Table truncated.
SCOTT@orcl12c> host sqlldr scott/tiger control=test2.ctl log=test2.log
SQL*Loader: Release 12.1.0.1.0 - Production on Mon Dec 16 13:11:40 2013
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
Path used: Conventional
Commit point reached - logical record count 2
Table TEST_TAB:
2 Rows successfully loaded.
Check the log file:
test2.log
for more information about the load.
SCOTT@orcl12c> select * from test_tab
2 /
SEQ EMPLOYEE ADDRESS_INFORMATION
1 Stewart Current Address: Street-A, Flat-507, London, UK
Permanent Address: Street-B, Flat-201, London, UK
2 Patrick Current Address: Street-A, Flat-507, Bangalore, India
Permanent Address: Street-B, Flat-201, Delhi, India
2 rows selected. -
Export data ready for sql loader
Hi,
I need to export some data from my database ready to be used by sql loader ... what are tools can I use? Using sqlplus (i.e. spool file.csv select c1||";"||c2||";" from table; spool off) is the only tool I can use?Hello,
You have multiple choices depending upon your oracle version on both source and target.
*1. Conventional export/import (no need to generate csv)*
*2. Datapump (10g)*
*3. Extracting .csv file using sql and loading using sqlldr*
*4. External table unloading data using datapump.*
*5. External table using .csv file generated via sql script.*
Regards
Maybe you are looking for
-
Is there a way to lock my MAC so it can't be opened without a special password?
Is there a way to lock my MAC so it can't be opened without a special password?
-
Scroll-zoom function does not work.
Hey, I am using Adobe Acrobat 6.0 Pro on Windows XP and somehow I am not able to use Ctrl+scroll for zooming in and out. It only works using Ctrl++ and Ctrl+-. Do you know how I can turn the scroll-zooming function on again? Thank you, Finn
-
"change" button is not visible in check status ?
HI, We are under upgrade of SRM 4.0 to SRM 5.0 . In SRM 4.0 "change" button is visible in check status even if shopping cart is under approval state. But in SRM 5.0 "change" button is not visible in check status if Shopping cart is under approval sta
-
Only oracle object tables to create object oriented database
Can we use only oracle object tables for a database and if it can be done, can we create pure object oriented database with oracle. How it can be done? help.. thank you..
-
[b]Events Managment Application[/b]
Hi All, I'm working on an events management application. The purpose of this application is to handle multipurpose events organized by my organization. Not sure what is the best practice to handle the following 1- On-line registration will be all