Unix shell script run from pl/sql procedure
Hi Guru
I want to run unix shell script from pl/sql procedure. Actual I want to run it from developer 10g form.
Please guide me in this regards
Regards
Jewel
Look at the host or client_host builtins in the help
Similar Messages
-
Calling stored procedure from unix shell script
Hello,
I am facing a problem while calling a stored procedure from UNIX shell script. I want to return a output variable from the stored procedure to the UNIX environment.
Here is the code-
#!/bin/sh
OUTPUT=`sqlplus cmag/magnum@dw <<ENDOFSQL
set serveroutput on;
var prd_out varchar2(100);
exec create_pm_window(:prd_out);
exit;
ENDOFSQL`
echo " output is - $OUTPUT"
The problem is :prd_out is not getting copied to shell variable OUTPUT.
I have a dbms_output.put_line in the stored proc create_pm_window and I can see that prd_out is getting populated.
Any help is really appreciated.
Thanks'
RakheeFirst step :
make sure the PL/SQL works as expected.
Does the following display the expected output executed from SQL*Plus ?
set serverout on
declare
prd_out varchar2(100);
begin
create_pm_window(prd_out);
dbms_output.put_line('output is '||prd_out);
end;
I don't have your procedure, but using a dummy procedure like :
Scott@my10g SQL>create procedure foo(p_out in out varchar2)
2 is
3 begin
4 select 'Hello '||instance_name into p_out from v$instance;
5 end;
6 /
Procedure created. and a toto.sh script as :OUTPUT=`sqlplus -s scott/tiger <<EOF
set pages 0 lines 120 trimout on trimspool on tab off echo off verify off feed off serverout on
var mavar varchar2(100);
exec foo(:mavar);
print mavar;
exit;
EOF`
echo "OUT = ${OUTPUT}"
exitIt works fine :[oracle@Nicosa-oel ~]$ ./toto.sh
OUT = Hello my10g -
Run Unix command / Run Unix shell script from Forms9i
Hi,
I have a requirement to run Unix command and Unix shell scripts from Forms9i.
I know HOST command cannot be used directly. I also know we can create some JAVA stored procedure to perform the task, but I don't want to create any JAVA stored procedure as there are some security concerns.
Please point me towards any other way to achieve the same.
I would really appreciate your help.
Thanks,
KumarThere is no reason why HOST can't be used. This is what it is for. As for using Java, it is not a stored procedure that you would be using, it would be imported Java (imported into the form).
The best way to use the HOST command is to call a script (.sh) rather than calling a Unix command directly. This is because HOST will not pick up environment variables set at the system level. So the script would first need to set the necessary environment variables then call the desired commands. -
Execute stored procedure from Unix shell script
My current method of executing stored procedures (wpl_1 and wpl_2) from a unix shell script is as follows:
<<wpl.sh>>
sqlplus user/password @/home/oracle/scripts/wpl.sql
<<wpl.sql>>
set serveroutput on size 1000000
set timing on
execute wpl_1('0000010676','~')
execute wpl_2('0000010676','~')
execute wpl_1('0000010236','FIX')
execute wpl_2('0000010236','FIX')
exit
Question: Is it possible to combine the two scripts (unix and oracle) together?A little rusty on this, but this may work:
My current method of executing stored procedures
(wpl_1 and wpl_2) from a unix shell script is as
follows:
<<wpl.sh>>sqlplus user/password @/home/oracle/scripts/wpl.sql << EOF
set serveroutput on size 1000000
set timing on
execute wpl_1('0000010676','~')
execute wpl_2('0000010676','~')
execute wpl_1('0000010236','FIX')
execute wpl_2('0000010236','FIX')
exit
EOF
>
Question: Is it possible to combine the two scripts
(unix and oracle) together? -
Controlling a procedure execution from a UNIX shell script
I want to control the execution of a PL/SQL procedure from a UNIX shell script.
Below, I include the script.
The control variable which should recive the return of the procedure, dosen't work well.
I want to control the return, because I wanr to make a UNIX script to control the execution of
a load data process with some Oracle procedures.
#!/bin/ksh
echo "Executing procedure pl/sql"
SQLPLUS="sqlplus -s /"
ESQUEMA="esquema1"
echo "\
call ${ESQUEMA}.Z_PROC_PRUEBA();" | $SQLPLUS
echo "Controlling pl/sql execution"
var_err=$?
if [ $var_err -gt 0 ]
then
echo "Error executing pl/sql"
else
echo "pl/sql finished sucessfully"
fiThis is not oracle problem. You can try something like this in your shell program ->
DEV=Udev01/1ods@ODS1
DEV_ID=`sqlplus -s ${DEV} <<!
set heading off feedback off verify off
set serveroutput on
@/prod/ods/satyaki/prac/ctl_build.sql '$1' '$3'; -- If you sql needs to pass argument
exit
!`
O_DIV_ID=`echo $DIV_ID | tr -s " " | sed 's/^[ ]//g'`
if [[ $O_DIV_ID -ne 0 ]]; then
echo "Successfully EXecuted.."
else
echo "Failed..."
fiHope this will help.
Regards.
Satyaki De. -
Call a UNIX shell script from an oracle stored procedure
We need to call a UNIX shell script from an oracle stored procedure
i.e. the control should come back to the procedure once the script completes. Can any body help to achieve this ?There are various ways in achieving this.
For Example, you can call a PRO*C-Library residing on the database server.
This requires a PL/SQL library to be generated and some changes to the Listener configuration.
It is also possible to implement a java procedure on the database being invoked by a PL/SQL wrapper class.
In this way (and if used right) there is also granularity regarding the filestructure permissions given and it may be called during a Forms or other PL/SQL session.
The article below explains a more generic approach how to invoke shell commands from within an Oracle Instance.
Be careful with this, because it really works ;)
Refer to :
http://www.oracle-base.com/articles/8i/ShellCommandsFromPLSQL.php
Message was edited by:
user434854 -
How can i call a Stored Procedure procedure from Unix shell script
Hi All,
I want to call a Strored PL-SQL Procedure through Unix shell script.
Can any body help me with this.
Regards,
SaurabhI prefer a seperate script like the other poster mentioned. However, most shells can use a 'here' document as well ...
sqlplus uid/pwd <<END
exec myproc
exit
ENDRichard -
Starting Unix Script from pl/sql procedure
I would like to start any unix shell script out of oracle.
I don't want use DBMS_PIPES, because then I always need a unix daemon.
Is there a package wich allows to a call similar to
"os_result := dbms_systemcalls.call_unix_system
('/usr/bin/ls -la');
nullWhat version of Oracle are we talking about here? If it's v8 then I think what you're after is a pl/sql external procedure which I can tell you how to set up.
Andy
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Christoph:
I would like to start any unix shell script out of oracle.
I don't want use DBMS_PIPES, because then I always need a unix daemon.
Is there a package wich allows to a call similar to
"os_result := dbms_systemcalls.call_unix_system
('/usr/bin/ls -la');<HR></BLOCKQUOTE>
null -
Do I run a shell script (bsh) via PL/SQL stored procedure?
Hello guys,
Do I run a shell script (bsh) via PL/SQL stored procedure?
For example:
procedure X is
(variables)
begin
-- Read file data
vFileHandle := utl_file.fopen('/mnt/novell/', 'file.txt','r');
exception
when 'INVALID READ FILE' then
(I've to try running script to mount a Novell partition.);
end;
I've to installed Oracle 9.0.1 on Suse Linux.
Please, any ideas or hints ...
Thx and regards.You might be able to us the HOST command, I think you'd have to run it via dbms_sql, check this page for more details, not sure if it'll be of help but its worth a try..
http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/server.817/a82950/ch8.htm
Cheers
Rob -
Need Example on calling a unix shell script from oracle stored procedure
Hi
Can anybody give example on how to call unix shell script from an Oracle stored procedure. Please give a small example on how to do this .I need this urgently please.
Have a nice time.
Thanks & Regards
JogeshIf you are on 10g you can also use DBMS_SCHEDULER. See Re: Excute Unix command Using PL SQL
-
Running SQLPLUS from UNIX shell script
I'm not sure if this is the right forum, but...
How can I execute a sql file from inside the UNIX shell script, logging on to Oracle w/o supplying a UID/pwd? Normally, we log into UNIX using our own logon, then sudo as another user to login to Oracle. Now, I'm trying to create a UNIX shell script, where I'm already sudo'd as the UserID that logs into Oracle. I've tried the following, but can't get it to work. I'm a UNIX scripting noob. Any ideas?
example:
#! /usr/bin/ksh
sqlplus / \@test.sql << EOF
exit;
EOFI'm a UNIX scripting noob.In which case I feel obligated to point you at William Robertson's excellent article Database Shellscripts Considered Harmful. Save yourself a world of pain.
Cheers, APC -
Running UNIX shell scripts from a Java app
I want to build a GUI in Java as a front-end to a collection of UNIX shell scripts I have written. Is this possible?
It is possible, but it kinda defeats the purpose of shell scripts no?
-
Run report from PL/sql procedure
Please any one tell how to I run a report from pl/sql procedure.
I am not sure, but depending on your environment you can create a script to run your PL/SQL code and then generate the report. As is customary in an UNIX environment utilizing shell scripts.
-
Unable to pass parameter in oracle procedure through unix shell script
Hi Experts,
I have oracle procedure where in I have to pass the value of procedure parameter through unix script.
Follwoing is the sample procedure which i tried to exceute from the unix.
Procedure:
create or replace procedure OWNER.PRC_TESTING_OWNER(OWNER IN VARCHAR2) AS
sql_stmt varchar2(1000) := NULL;
v_count number := 0;
v_owner varchar2(100) := owner;
begin
sql_stmt:='select count(1) from '||v_owner||'.EMP@infodb where rownum<=10';
execute immediate sql_stmt into v_count;
DBMS_OUTPUT.PUT_LINE(sql_stmt);
DBMS_OUTPUT.PUT_LINE(v_count);
END;The script which I used is:
Unix
#!/bin/ksh
parm=$1
echo start
sqlplus -s scott@DEV/tiger <<EOF >>result_1.txt
set serveroutput on;
select '$parm' from dual;
exec owner.PRC_TESTING_OWNER('$parm');
EOFThe script is working fine that is i am able to pass to parameter value through unix shell script. :)
But if I want to pass the value of the owner in cursor , I am unable to pass this value through unix.
Following the procedure which i am trying to implement.
create or replace procedure OWNER.PRC_TESTING_OWNER(OWNER IN VARCHAR2) IS
v_owner varchar2(100) := owner;
CURSOR main_cur IS
select
i.ROWID rid ,
emp_name,
deptid
from v_owner.employee;
CURSOR subset_cur(c_deptid NUMBER ) IS
SELECT *
FROM v_owner.DEPT d
where d.dept_id=c_deptid;
--##main loop
FOR i IN main_cur LOOP
FOR j IN subset_cur(i.deptid) LOOP
BEGIN
insert into v_owner.RESULT_TABLE
END;
END LOOP;
END LOOP;How can i pass parameter value of the stored procedure through unix script(that is "owner" in this case), when these parameter value is
used in cursor? :(
Can anybody help me regarding the same?
Thanks in Advance !! :DIt's not the parameter in the cursor that is the problem, it's that you are trying to use static SQL for something that won't be known until run time (the owner of the table).
You would need to use something like ...
declare
l_owner varchar2(30) := 'SCOTT';
l_ref_cursor sys_refcursor;
type l_ename_tab is table of scott.emp.ename%type;
l_ename_array l_ename_tab;
begin
open l_ref_cursor for
'select ename
from ' || l_owner || '.emp';
loop
fetch l_ref_cursor bulk collect into l_ename_array limit 10;
exit when l_ename_array.COUNT = 0;
for x in 1 .. l_ename_array.count
loop
dbms_output.put_line(l_ename_array(x));
end loop;
end loop;
close l_ref_cursor;
end;
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01 -
Calling a report from unix shell script
Hi,
I had to call a report from unix shell script.
May i know the procedure to accomplish this
Thanks in Advance
A.GopalFirst you should not include the whole path to your report in the call ...
Use like this:
/ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
In $ORACLE_HOME/bin/reports.sh:
1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
i.e.
Change the following line:
<!--trace traceOpts="trace_all"/-->
to <trace traceOpts="trace_all"/>
Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look.
Maybe you are looking for
-
All day events don't show on wiki calender
for some reason any all day events i put in ical doesn't update on the wiki, its fine for any other events that aren't all day, has anybody found a solution for this? Also is it possible to colour code events?
-
Solaris 10 Sparc - 64-bit jdk/jre in use?
Hello, I have the latest version of Java jre/jdk installed on by Sun, including the 64-bit Java in the sparcv9 directories (/usr/jdk/instances/jdk1.5.0/bin/sparcv9). All the Java programs are in their default locations, and I have not changed any sym
-
How can I get rid of Browser hijacker in Firefox and Chrome please?
I was on a website today and it was full of pop up ads. I think I might have clicked on something by mistake and all of a sudden my webpage was being redirected every time I tried to do something. The last one led me to a blank page with something ab
-
How to delete a record from BSEG table
Dear Experts, How to delete a record from BSEG table. If there possible to delete some records from transparent table ? Please help. Regards, Tan
-
what can be done to avoid getting the following error when trying to delete unused clips in Imovie 09 "the operation could not be completed. *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil" I use to get these type of error messages wh