Could I call SQL Loader in PHP?
Hi.
I a newer using oracle with PHP. I want to import data to database.
I am using SQL Loader tool. It is good for import data.
Now, I want to call command from PHP. Can I call it from PHP or Not?
Thank for your help.
Rac
Hi,
Yes. You can invoke SQL*Loader using php exec. function: http://pl.php.net/manual/en/function.exec.php
Please read all security warnings related to this function.
Regards, Paweł
Similar Messages
-
Hello,
I'm currently trying to call the SQL Loader in a php-script in order to enable users to upload data by themselves by a simple button-click. I tried several things however everytime I'm clicking on the button, nothing happens.
my code looks as follow:
if ($upload_csv == "1") {
$command="SQLLDR *Scheme*/*Passwrd*@*server* log='*server*/abc.log' control='*server*\abc.ctl'";
chdir("\\*server*\UPLOAD");
$exec(command);
I also tried it in several other ways, for examle calling the sql-loader-command directly or without the command-variable, however nothing worked.
Am I doing something wrongActually we're using MS Windows Server 2003 and also the call of the SQL Loader shouldn't be any problem as I called the Loader via batch-file on the server directly and it worked just fine - only calling the Loader or even the batch-file via PHP doesn't work...
Well, I tried something out and moved the php-script to another folder and all of a sudden I started to get error-messages printed on the sceen.
Tried it then in 2 ways - once with the command "$sell_status = shell_exec(abc.bat);" and got this error message back: CGI Error - The specified CGI application misbehaved by not returning a complete set of HTTP headers.
Afterwards I also tried it with the exec()-Command and got this error-message back: Fatal error: Function name must be a string in - C:\Inet\root\Intranet\db_admin\test.php on line 14 -
Calling SQL * LOADER in stored procedure
Hi Experts,
Can we call sql*loader in stored procedures? . If yes , please let me know the syntax.
Any help will be highly appreciated.
Thanks.You can also use dbms_schedular to execute any shell or batch file - i guess ->
BEGIN
-- UNIX
DBMS_SCHEDULER.create_job(
job_name => 'unix_command_job',
job_type => 'EXECUTABLE',
number_of_arguments => 1,
job_action => '/bin/ls',
auto_drop => FALSE,
enabled => FALSE);
DBMS_SCHEDULER.set_job_argument_value('unix_command_job',1,'/tmp');
DBMS_SCHEDULER.set_attribute('unix_command_job', 'credential_name', 'TIM_HALL_CREDENTIAL');
DBMS_SCHEDULER.set_attribute('unix_command_job', 'destination', 'marge.localdomain:65001');
DBMS_SCHEDULER.enable('unix_command_job');
END;For details ->
http://www.oracle-base.com/articles/11g/SchedulerEnhancements_11gR1.php
http://www.oradev.com/dbms_scheduler.jsp
http://www.psoug.org/reference/dbms_scheduler.html
Regards.
Satyaki De. -
Issues in calling Sql Loader through forms developer (10g)
Hi,
I am developing a form(in 10g) ,in which I am calling sql loader for loading data onto a oracle database table from external source (e.g. data file is a .CSV file).
But , somehow the sql loader is not getting executed.
Here , I am giving the environment settings , approach i am taking;
This is a distributed system , both the application server,and database server are mounted on two different servers.
The form is delpoyed on the application server.
The database table , and the sql loader are configured on the databse side.
I am using host(<sql loader command>) command to invoke the Operating System command through forms.
The sql loader is working ok , and the data is getting loaded successfully onto the required database table when I am executing the sql loader command on Unix prompt , but through the forms , it's not working.
Do I need to change some environmental setting to make this work...
Any quick help in this regard is highly appreciated.
Thanks.Hi Craig,
I have already tried out the option of calling sql loader through stored procedure,but this is not working ...
could you please share any examples to do so ...
code snippet i am using in forms:
declare
usid get_application_property(userid);
pwd get_application_property(password);
db get_application_property(host);
msqlldr varchar2(250);
begin
msqlldr:='/u01/oracle/formss/bin/sqlldr' username=<uid/pwd@db> control=<control file name> data=<data file name> log=<log file name>
hosts(msqlldr);
end;
Note that sqlldr command ,for that matter any unix shell command is not working through the hosts() command ...
could you please suggest any way out ...
Thanks. -
How to Call SQL Loader from Java ( servlet )?
We need to call SQL Loader command from Java Servlets? Any suggestions how this can be done?
Thanks
RahulProbably not the best way, but you could try using JNI to call a C function which then invokes SQL Loader via system() or exec(). I haven't done this myself though...
-
Hi all, i am trying to load a file called text1.txt using sql loader. I am using sqlplus but i dont know how to call sql loader in sql plus.
can someone provide syntax assumming data file is text1.txt and control file is txt.clt
thanksWhy on earth? Though you forgot to include version info, assuming you are not using 9i or older, you can and should use the external table facility and you don't need this unstable and resource consuming procedure.
If you would have thought even one second about solving your own problem, you would have realized sqlloader is a separate O/S utility, which requires the host command, and username/password on the commandline.
That alone is a reason not to do it.
Sybrand Bakker
Senior Oracle DBA -
Help in calling sql loader and an oracle procedure in a script
Hi Guru's
please help me in writing an unix script which will call sql loader and also an oracle procedure..
i wrote an script which is as follows.
!/bin/sh
clear
#export ORACLE_SID='HOBS2'
sqlldr USERID=load/ps94mfo16 CONTROL=test_nica.ctl LOG=test_nica.log
retcode=`echo $?`
case "$retcode" in
0) echo "SQL*Loader execution successful" ;;
1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
3) echo "SQL*Loader execution encountered a fatal error" ;;
*) echo "unknown return code";;
esac
sqlplus USERID=load/ps94mfo16 << EOF
EXEC DO_TEST_SHELL_SCRIPT
it is loading the data in to an oracle table
but the procedure is not executed..
any valuable suggestion is highly appriciated..
Cheersmultiple duplicate threads:
to call an oracle procedure and sql loader in an unix script
Re: Can some one help he sql loader issue. -
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 SQL Loader with Dynamic file names
HI all
I woul like to know if I can call sql loader as below
$ sqlldr userid=uname/pwd control=new.ctl, data=$1
I have to schedule my loader 3 times a day and each time my file names are different(AAA_BBB_timestamp)
ThanksI have found a solution myself and if any one is interested its like this
for file in `ls -1 /opt/user/from/`
do
sqlldr userid=user/pwd@connect_string control=control_file.ctl data="/opt/user/from//$file"
done
Ramu -
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 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 Forms 4.5 using HOST command in Win2000
One of my forms calls SQL Loader 7.3 using HOST command to load a csv file onto the database(Oracle 7.3) under Windows 2000 platform.
Only after sql loader finishes its operation the control should come to my form i.e. synchronous execution.
As of now its running asynchronously.
Is there any way to make it synchronous. If Not any other work arounds?
Environment Details
Forms [32 Bit] Version 4.5.10.6.0 (Production)
Windows 2000 Operating System
Oracle7 Release 7.3.2.3.2Forms6i running on W2000, Rdbms 8.1.7
in Forms I added a button TEST,
Trigger when-button-pressed : host('test.bat') ;
in directory .......\frm I added file test.bat :
REM ===============
cd /d C:\........\ldr
pause
sqlldr parfile=test.par
pause
type test.log
pause
exit
REM ================
now, pressing TEST button opens DOS window, telling me what's going on, running sqlldr, finally going back to forms
Are you using NO_PROMPT or NO_SCREEN option of HOST command ?
Had a look at Forms 4.5 manuals, there is no mentioning of (a)synchronously operation in connection with HOST command. -
How to call sql loader ctrl file with in the pl/sql procedure
Hi Friends,
I am doing a project related with the transferring data using queues. In the queue , I will get a tab delimited data in the form of CLOB variable/message. I do want to store that dat in the oracle table.
When updating data into the table ,
1. Don't want to write that data into a file.( Want to access directly after dequeueing from the specfic queue).
2. As the data is in tab delimited form, I want to use sql loader concept.
How do I call the sql loader ctrl file with in my pl/sql procedure. When I searched , most of the forums recommending external procedure or Java program.
Please Guide me on this issue. my preferrence is pl sql, But don't know about external procedure . If no other way , I will try Java.
I am using oracle 9.2.0.8.0.
Thanks in advance,
Vimal..Neither SQL*Loader nor external tables are designed to read data from a CLOB stored in the database. They both work on files stored on the file system. If you don't want the data to be written to a file, you're going to have to roll your own parsing code. This is certainly possible. But it is going to be far less efficient than either SQL*Loader or external tables. And it's likely to involve quite a bit more code.
The simplest possible thing that could work would be to use something like Tom Kyte's string tokenization package to read a line from the CLOB, break it into the component pieces, and then store the different tokens in a meaningful collection (i.e. an object type or a record type that corresponds to the table definition). Of course, you'll need to handle things like converting strings to numbers or dates, rejecting rows, writing log files, etc.
Justin -
I am writing a Java application running on SUN Solaris to perform data feed from a number of csv files to ORACLE. I am to use SQL Loader to perform the loading. What I need is to kick off the SQL Loader in my code. My question is how to kick off the SQL Loader in Java.
One of option I am thinking is using RunTime.Exec(). Is the following code workable?
runtime.exec( "sqlldr CONTROL=foo.ctl, LOG=bar.log, USERID=scott/tiger" );
Althernatively should I write a Oracle store procedure to call the SQL Loader and Java call the store procedure?
Any thoughts and directions are welcome!
Regards,Hi,
Can't you achieve the same thing using this
Class.forName("Driver");
Connection ocon=DriverManager.getConnection("url");
Once you have ocon then you can execute any query.
If this is not what you want,can you explain what SQLLoader means here?
Regards
Vicky -
Hi All,
Is there any way to call the sql loader in Apex to load the table with csv data.
Thanks in advance
DhanDo you need the application to load data for users as a function or are you just trying to load some data. Application Express has loading/unloading utilities from the main workspace menu that you can use for one time loads.
Maybe you are looking for
-
Error while running converted JCL / proc from Tuxedo Workbench
Hi , I am trying to convert and run a JCL / Proc and Cobol code through Oracle Tuxedo Rehosting Workbench . I followed all the steps and deployed the components . This created .ksh components for JCL in ../deploy/JCL and .proc component in /deploy/
-
I created my first website using iweb but was dissappointed to find that when I published it, it did not look the same as before. Blocks of text that I'd carefully arranged to fill a space did not behaved as I'd intended. Instead lines spilled over c
-
Hello, I have the following error messages when i check the alert monitor in dbacockpit and the bottlenecks in LC10: Critical Logging Event Error OM13 High : Log_WriterTaskSynchronizer::m_spinlock: collision rate 0.02%, 1 collisions, 30000 spin lo
-
When I am typing an email and it saves automatically as a draft sometimes it will save it several times with each version having the changes instead of just re-saving to the already saved version. Then when I send the email those multiple drafts don'
-
Personal Hotspot get Disconnect.
I have Iphone 4 , udate to IOS 7 , 7.0.3 My Personal hotspot gets disconnet in between, connected to my Desktop & other mobile.. please help me out...