Calling SQL Loader from SQL Plus
Hi everyone,
I currently use both SQL Loader and SQL Plus to load data and to then carry out certain DML tasks and to reinstate indexes. That all works fine but of course I need to be present to start and to monitor the various scripts.
What I would really like to do is to be able to incorporate the calls to SQL-Loader into my SQL-Plus scripts and am wondering if this is possible.
At the moment I run some parts of the load in 'batch' (i.e. command line calls to SQL-Loader and to SQL-Plus) but this won't work for the whole load because the batch calls (from Windows) are not able to wait for particular processes to finish before they start the next. This works OK for the SQL-Loader scripts (because they can run in parallel) but will not work for the whole load because the load needs to be finished before the further processing starts.
Or maybe there is a way (Windows .BAT files?) to set up batch processes which are intelligent enough to wait for one action to finish before starting the next action.
Any thoughts or any links to HOWTOs on this would be a great help.
Regards and thanks,
Alan Searle
Hi Alan,
In SQL*Plus you have the HOST command.
I would go for the .bat solution using [START /WAIT|http://www.computerhope.com/starthlp.htm]
Regards
Peter
Similar Messages
-
Calling SQL*Loader from Forms
Hi,
I was wondering if anyone has called SQL*Loader from Forms?
What I am wanting to do is use Oracle Forms as the interface where you can specify a file that you can import into the database and it will use a set control file. Push the import button and SQL*Loader does the rest.
Is using Java code to call SQL*Loader from Forms a viable option, or is there an easier way to achieve the desired outcome.
Any ideas or guidance will be much appreciated.
Thanks,
Scott.Scott,
In forms, there's a HOST built-in command which is supposed to execute any o/s commands.
What you have to do is :
1. Bult up the string exacltly in the fashion which you will run in o/s
2. Call the HOST Built-in and pass in the string
Here's a example :
Declare
lOsCmd Varchar2(1000) := Null;
Begin
lOsCmd := 'sqlldr user-id=userid/passwd@connectStr '
|| ' control=c:\temp\abc.ctl log=c:\temp\abc.log '
|| ' bad = c:\temp\abc.log';
Host (lOsCmd, No_Screen);
End;
-- Shailender Mehta -- -
Calling a function from sql*plus
I can call my procedure from sql *plus
by doing
sql>call Proc_name(x,y);
How do you call a function?
nullJohn,
I think moifying the statement
CREATE OR REPLACE PROCEDURE "OGUSER"."OGX1" (user_county in integer, user_permit in integer )
TO
CREATE OR REPLACE FUNCTION "OGUSER"."OGX1" (user_county in integer, user_permit in integer ) return NUMBER is
AND before end you will have to add a return statement
(Probably
return 0;
exception
when others then
return 1;
end;
This will change your procedure to a function but I am not sure you'll be able to see your dbms_output's, if you call the function using select ...
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by john saucer ([email protected]):
I want to turn my procedure into a function.
So I can call it with a select statement.
I'm kind of having problems with the return statement at the top and bottom.
I don't quite understand how to declare the type in the return. My procedure calculates 2 pl/sql tables....
My procedure looks like.
CREATE OR REPLACE PROCEDURE "OGUSER"."OGX1" (user_county in integer, user_permit in integer )
as
i integer :=0;
j integer :=0;
type dept_table_type is table of ogxtest%rowtype
index by binary_integer;
type dept2_table_type is table of ogxtest%rowtype
index by binary_integer;
my_dept_table dept_table_type;
my_dept2_table dept2_table_type;
v_cotemp number := user_county;
v_permittemp number := user_permit;
v_origcotemp number := user_county;
v_origpermittemp number := user_permit;
v_count number(2) :=1;
v_count2 number(2) := 1;
v_oldcount number(2) :=1;
v_oldcount2 number(2) := 1;
begin
select count(*) into v_count from ogxtest where oco=v_cotemp and opermit=v_permittemp;
select count(*) into v_oldcount from ogxtest where nco=v_cotemp and npermit=v_permittemp;
while v_count >= 1 LOOP
i := i+1;
v_count2 := v_count2 +1;
select *
into my_dept_table(i)
from ogxtest where oco=v_cotemp and opermit=v_permittemp;
v_cotemp := my_dept_table(i).nco;
v_permittemp := my_dept_table(i).npermit;
select count(*) into v_count from ogxtest where oco=v_cotemp and opermit=v_permittemp;
end loop;
while v_oldcount >= 1 LOOP
j := j+1;
v_oldcount2 := v_oldcount2 +1;
select *
into my_dept2_table(j)
from ogxtest where nco=v_origcotemp and npermit=v_origpermittemp;
v_origcotemp := my_dept2_table(j).oco;
v_origpermittemp := my_dept2_table(j).opermit;
select count(*) into v_oldcount from ogxtest where nco=v_origcotemp and npermit=v_origpermittemp;
end loop;
for i in 1..v_count2-1
loop
dbms_output.put_line(' reassigned to - orig county ' | |my_dept_table(i).oco | | ' orig permit ' | |my_dept_table(i).opermit| | ' new county ' | |
my_dept_table(i).nco | | ' new permit ' | |my_dept_table(i).npermit );
end loop;
for j in 1..v_oldcount2-1
loop
dbms_output.put_line(' reassigned from - orig county ' | |my_dept2_table(j).oco | | ' orig permit ' | |my_dept2_table(j).opermit| | ' new county ' | |
my_dept2_table(j).nco | | ' new permit ' | |my_dept2_table(j).npermit );
end loop;
end;
<HR></BLOCKQUOTE>
null -
Calling oracle SQL Loader from java program
Hi,
I want to insert data into oracle tables from a text files containing fixed length fields. I am using SQLLoader to achieve this. The requirement is to call the SQLLoader within the java program.
Does anyone know how to call SQL Loader from java program?
Thanks,
VarshaSimply "exec" the sqlldr program with the parameters you need to pass to it.
Runtime.exec (........)
Try to pass all parameters needed including the username and password, and use the option "silent" to avoid output, and the option "log" to have a log file of the modifications that sqlldr has done to the database. -
Calling Sql-loader from PL/SQL
What is the command(s) to call Sql-Loader from inside a PL/SQL procedure?
Regards,
Ahmad.I don't think it is possible ...
-
Calling SQL*Loader from OCCI
Hi All,
I need to access SQL*Loader from C++.
I know there is an interface for OCI to access SQL*Loader.
I also know there is a gnu project of a c++ wrapper to the OCI-SQL*Loader interface (odpd).
According to the OCCI documentation it is just a C++ facade of OCI (with some goodies like thread managing , etc.).
I want to know the following:
1. How can I operate OCI from OCCI?
2. Are there are source samples of operating OCI from OCCI or even better operating OCI SQL*Loader interface from OCCI?
3. Are there are any known (/unknown :-) ) problems with either OCCI access to OCI or OCI interface itself to the SQL*Loader?
Thanks,
ArikHi,
If you have a OCCI application and you want to interoperate with OCI, you can retrieve the underlying OCI handles from OCCI objects and write OCI code.
e.g :-
//with Environment env, Connection conn OCCI objects
OCIEnv *ocienv = env->getOCIEnv();
OCISvcCtx *ocisvc = conn->getOCISvcCtx();
//use OCI calls
OCIError *errhp;
OCIHandleAlloc (ocienv, &errhp, OCI_HTYPE_ERROR,...);
OCIHandleAlloc (ocienv, &dpctx, OCI_HTYPE_DIRPATH_CTX,..);
err = OCIDirPathLoadStream(...);
OCCI does not have a direct path API at present.
Thanks. -
Calling Sql*Loader from oracle Form builder
How do i call sql* loader from my forms to import the external data in different formats into my existing database?
Specify the flexibility of sql* loader to import external data from .txt files or .xls files.
Would be thankful if certain examples are given along with the answer.Hi,
1. First you have to create seperate ctl (Control files) which maps to different file formats
2. Using Oracle Forms,
2a) You can use the 'HOST' command to execute the command line ie. In this case executing
SQL*Loader script
2b) You also have the feature in ORACLE forms to read text files and load the data into
ORACLE db.
This can be achieved by using TEXT_IO package which comes with ORACLE Forms.
Hope this helps
Ta
Shailender -
Calling SQL LOADER From Java Program
Hi
I need to invoke sql loader from inside a Java Class.
Any Pointers in this regards will be really appreciated.
Thanks
VishalYou can create two different files which has sqlldr command defined....
1. loader.sh
2. loader.bat
and in the depending on the OS execute one...
String command = "";
if(System.getProperty("os.name").equals("Windows 2000")){
//if os is windows 2000 then execute bat file
command = <<bat file path>>
}else{
command = <<shell path>>
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(command);
int i = p.exitValue();
-
Invokin SQL*Loader from a stored procedure
I try to invoke SQL*LOADER from within a database package by using external C procedure (the procedure calls the system() C function) but the loader generates the following error in its log file :
SQL*Loader -523: error -2 writing to file (STDERR)
and no data is uploaded.
I have tried to use system() from within database procedures to execute OS commands and it works. Does anyone know what is the problem with using system() to execute "sqlldr <parameters>"? Is there some other way to call the loader from within a stored PL/SQL procedure?
Thank you very much for your help.
Aneta Valova
nullHi
What is your task and why you are trying to invoke SQL*Loader from strorage procedure or package? Maybe the redirecting of stderr will resolve your problem but thik is it the best way to do your job.
I am not sure, that invoking other executables from Oracle instance is good idea.
Regards
null -
Hello!
How can i call to SQL Loader from my application developed by Forms 10?My application is doing something similar.
Given that the iAS server can read from the data source (where the flat file for the sqlldr to load), all you need is to write a shell script that is invoked from within the forms application (using the host command). The shell script (I use Perl) will do invoking the sqlldr and also other checks, etc
hope this helps -
hi,
can any one tell me how to call sql loader from forms 9i
thanks
vikram.Hi,
How to execute SQLLDR from web forms in IAS.
You need to set the ORACLE_HOME to the one which has sqlldr.
You can create a DOS BAT file like this for Windows and call this
using the HOST built-in.
If you are using this on web then the HOST will execute in the
Application Server machine. So, files should be in that machine.
REM=======For Windows===============
REM filename Mysqlldr.BAT
REM my file to execute sqlldr
set ORACLE_HOME=D:\oracle\iSuites
set PATH=D:\oracle\iSuites\bin;%PATH%
sqlldr scott/tiger@l817 D:\Mycontrol.ctl DATA=mydata.dat LOG=mylog.log BAD=mybad.log
REM======================
Similarily, you can create a Shell script for UNIX system.
Source: Metalink
~KBK -
Invoke SQL Loader from PL/SQL Procedure
hi
Is there any way to invoke sqlloader from a PL/SQL Procedure ?
Thanks
Ashish'HOST' is not a PL/SQL command, it's a SQL*Plus command.
If you think about it for a moment, being able to run an O.S. command, such as SQL*Loader, from within the database is pretty dangerous. I suspect this is why Oracle has no way of doing it. Otherwise, a you'd be able to execute an O.S. command as the user 'oracle' (on UNIX - probably 'SYSTEM' on NT, which is even worse!!!).
All it takes is to change this :
execute '/usr/oracle/bin/sqlldr user/password@DB file=input.txt' ;
to this :
execute 'rm -rf /usr/oracle' ;
and you can start checking the job adverts... -
Launch the SQL*Loader From Stored Procedure???
Is it possible to aaunch the SQL*Loader from a stored procedure? Please help!
Try the documentation on external procedures
-
Invoking SQL Loader from linux - Help Needed
Hi All,
When i tried to invoke the sql loader from linux by using following command
sqlldr username@server/password control=loader.ctl
But its always throws this message
Message 2100 not found; No message file for product=RDBMS, facility=ULMessage 2100 not found; No message file for product=RDBMS, facility=UL
Can somebody help me to fix this issue?You may need to set your Oracle environment, try this ($ is the command prompt):
$ export ORACLE_SID=orcl
$ . /usr/local/bin/oraenv
$ sqlldr username@server/password control=loader.ctl:p -
Sample code of how to execute sql loader from visual basic
Hi,
Can anyone please provide me with sample code of how to
run sql loader from inside a visual basic 6.0 application with Oracle 8.1.7.3 database or please point me to documentation/tech books containing such examples?
Thanks very much
JohnYou have to use the command shell to activate a file.bat. The Shell command has the following parameters :
Shell(Pathname, Windows Style )
[email protected]
Joel P�rez
Maybe you are looking for
-
ABAP Sample code for HR_MAINTAIN_MASTERDATA
Hi folks, I want to delimit a record in the HR master Table wi the help of Function Module HR_MAINTAIN_MASTERDATA, but its not updating HR master table correctly so please send me some sample code for that function module. usefull points will rewarde
-
I won't have WiFi available at work, but can I update my iTouch and emails when syncing at work to both Gmail and Gmail calendard? How has anyone dealt with this at work? Thanks in advance for any experience or ideas.
-
Lightroom 1.1 stalls (and apparent stalls)
I've been trying to track down a couple of reported stalls with Lightroom 1.1 and I thought I would update people with what I've found. * Metadata Browser updates. Lightroom updates the metadata browser based on having a list of photos for which the
-
I cannot change time in NEW EVENT scheduler box
The time has a letter in the hour place. It can be highlighted but will not change to a number
-
Query to get the contents of the package body
What is the query that can be used to get the contents of the package body?