Unix call to Oracle PL/SQL pkg/store.proc


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix call to Oracle PL/SQL pkg/store.proc
# 1  
Old 09-20-2002
Data Unix call to Oracle PL/SQL pkg/store.proc

HI,

I'm trying to get this right, please can you help. In my unix korn shell script, I call an oracle stored proc within a package and I specify 3 parameters, 2 of which are IN OUT parameters (i.e. I expect the stored proc to change them and return them back to me).

Does the unix code look ok and I using the bind variable in the right way syntactically???

Here's the code:

In Unix:
======
ERROR_NO_OUT=0
ERROR_TEXT_NO="N/A"

sqlplus -s ${DB_UNAME}/${DB_UPSWD}@${DB_NAME} << END_OF_SQL
exec psit_ba_upload_pkg.apply_jobs('18/09/2002',:$ERROR_NO_OUT, :$ERROR_TEXT_NO)
END_OF_SQL

echo "ERROR_NO_OUT=$ERROR_NO_OUT\n"
echo "ERROR_TEXT_NO=$ERROR_TEXT_NO\n"




In Oracle:
=======
CREATE OR REPLACE PACKAGE chee_psit_ba_upload_pkg AS
PROCEDURE apply_jobs(p_business_date IN VARCHAR,
error_no_out IN OUT INT,
error_text_out IN OUT VARCHAR2);
END chee_psit_ba_upload_pkg;
/

CREATE OR REPLACE PACKAGE BODY chee_psit_ba_upload_pkg AS
PROCEDURE apply_jobs(p_business_date IN VARCHAR,
error_no_out IN OUT INT,
error_text_out IN OUT VARCHAR2)
IS
BEGIN
...
EXCEPTION
WHEN OTHERS THEN
error_no_out := 1;
error_text_out := 'Error retrieving data for the business units. ' || TO_CHAR(SQLCODE) || ' : ' || SQLERRM;
ROLLBACK;
RAISE;
END apply_jobs;

END psit_ba_upload_pkg;
/
# 2  
Old 09-20-2002
In sqlplus, if you run 'exec psit_ba_upload_pkg.apply_jobs('18/09/2002',0, N/A) ' does it return any errors? Try typing 'show err' after the exec completes in sqlplus and see if it tells you anything. I think the problem may be the lack of ' around your variables as you call the exec.
# 3  
Old 09-22-2002
Update

You need to define the bind variables to SQLPLUS and set a unix variable to contain the returned variables, then parse them in unix using something like awk or cut
In Unix:
======
ERROR_NO_OUT=0
ERROR_TEXT_NO="N/A"

l_string_returned = `sqlplus -s ${DB_UNAME}/${DB_UPSWD}@${DB_NAME} << END_OF_SQL
-- define them
var error_no_out number := $ERROR_NO_OUT;
var error_test_no varchar2 := $ERROR_TEXT_NO;
exec psit_ba_upload_pkg.apply_jobs('18/09/2002',:ERROR_NO_OUT, :ERROR_TEXT_NO);
print :error_no_out,:error_text_out;
END_OF_SQL`

Echo $l_string_returned

-- parse em out here to unix varaiables using awk or cut.

#echo "ERROR_NO_OUT=$ERROR_NO_OUT\n"
#echo "ERROR_TEXT_NO=$ERROR_TEXT_NO\n"
# 4  
Old 01-07-2008
Calling stored proc to run at different regions

I have a requirement to write a shell script that calls stored proc.
The stored proc should run for different regions(Asia, Europe) at the same time.

Please suggest best ways to achieve this.

Thanks in advance.
# 5  
Old 01-07-2008
Quote:
Originally Posted by Sathy153
a shell script that calls stored proc.
If this is Oracle, then this can be done with SQLPLUS.

Quote:
Originally Posted by Sathy153
The stored proc should run for different regions(Asia, Europe) at the same time.
Look at cron for scheduling.

What you are doing with time zones is up to you.
# 6  
Old 01-07-2008
Calling stored proc to run at different regions

Thanks for the quick reply.

Yes. I am using SQLPLUS.

Could you please elaborate on cron scheduling..

Many thanks in advance.
# 7  
Old 01-07-2008
Search this site for the word "crontab" and you will find many examples.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parallel execution of Oracle PROC in UNIX

Hi, Trying to run the Oracle Proc in parallel, but not working.. below code runs each call of the procedure and its coming out of the loop before its completion and printing the last statement! not waiting for the sqlplus to complete. for name in `cat abc.txt` do (sqlplus -s ... (3 Replies)
Discussion started by: ATWC
3 Replies

2. Shell Programming and Scripting

Sybase Stored Proc call from UNIX script.

Hi, I am new to shell scripting and Sybase database i need a help that i try to execute a SYBASE stored procedure from a Unix shell script and wanna write the output of the SP into a Text File.somehow i try to find a solution but whwn i try to run the script i am not getting the output file with... (1 Reply)
Discussion started by: Arun619
1 Replies

3. UNIX for Dummies Questions & Answers

Call SQL LOADER FROM UNIX

HI Experts, I am pretty new to scripting and i need to create a perl or shell script which should fetch a file from local directory and insert the data into a table using sql loader. This will be later added to chron job to run daily and fetch all files and load them into the table. Also i... (1 Reply)
Discussion started by: sam1234
1 Replies

4. UNIX for Dummies Questions & Answers

Call SQL LOADER FROM UNIX

HI Experts, I am pretty new to scripting and i need to create a perl or shell script which should fetch a file from local directory and insert the data into a table using sql loader. This will be later added to chron job to run daily and fetch all files and load them into the table. Also i... (1 Reply)
Discussion started by: sam1234
1 Replies

5. Solaris

Pkg problem, one zone trying pkg.Oracle.com on port 1008

Hi Solaris Experts, The pkg utility on one of my non-global zones has stopped working, it's trying to connect to port 1008 at pkg.oracle.com I was using pkg successfully from this zone, but now it's showing this error: lzone1 $ pkg search xterm pkg: Some repositories failed to respond... (4 Replies)
Discussion started by: ad101
4 Replies

6. Shell Programming and Scripting

To call a Oracle sql file 1000 times

Hi Guys, Even though, i have called db2 sql file earlier, this is my first time to call a oracle sql file. I need to make a database(oracle) connection and then call the sql file in a loop. Can you please help me out. Thanks for your help and time. Regards, Magesh (4 Replies)
Discussion started by: mac4rfree
4 Replies

7. Shell Programming and Scripting

Call a pl sql function from unix

hi, I want to know how to call a pl sql function testfunction(param1,..) that returns a value and grab that value in a shell variable. Thnx in advance ---------- Post updated 03-30-10 at 11:58 AM ---------- Previous update was 03-29-10 at 03:49 PM ---------- thnx a lot jim (0 Replies)
Discussion started by: austinhell3_16
0 Replies

8. Shell Programming and Scripting

Can SQL Server call be made from unix sh

Hi, I need to make SQL Server procedure call (exec <proc name>)from unix shell script. First of all I would like to know if it is possible. I know we can do it from Oracle but not sure about SQL Server. Version: SunOS 5.8 SQL 8.0 I have made the below entry in the interface file. NSXNA267 ... (0 Replies)
Discussion started by: sspreethi
0 Replies

9. UNIX for Advanced & Expert Users

How to call SQL procedure from UNIX Shellscript ?

Hi All I would be thankful to you all if you will guide me the steps to call a stored proc. from unix shell script. that stored proc. could be parameterised or parameterless developed in SQL. Any info. in this topic would help me..... Thanks in advance.... (1 Reply)
Discussion started by: varungupta
1 Replies

10. Shell Programming and Scripting

How to call pl/sql in unix script

sample code as following: test_sql(){ #test#echo test_sql str=`$ORACLE_BIN/sqlplus -s $user/$passwd <<EOM set verify off set heading off set feedback off #--------start pl/sql { DECLARE CURSOR pah_cs IS select id from table where letter = 'abcd';... (6 Replies)
Discussion started by: YoYo
6 Replies
Login or Register to Ask a Question