DB2 stored procedure (with input parameters) from script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting DB2 stored procedure (with input parameters) from script
# 1  
Old 12-12-2006
DB2 stored procedure (with input parameters) from script

I have a db2 stored procedure on my database which require 3 parameters, I have the following db2 command in a sql script

Code:
    CONNECT TO SAMPLE;
   CALL BACKUP(INPUT_1, INPUT_2, INPUT3);

Usually, I would just invoke this sql script from my shell script like below

Code:
    db2 -tf my_sql_script.sql -z logfile.txt

However, how can I pass these 3 user input parameters from shell script to my sql script? Can this be done?

If not, I can simple call invoke these sql command directly in my shell script, but how would I redirect all the messages from executing my DB2 stored procedure to a log file?

Thanks in advance!
# 2  
Old 12-13-2006
If your .sql file always contain this two line only ??? then
you can write a function in unix script like this -

function ExecuteDB2Proc
{
Dname=$1
INPUT_1=$2
INPUT_2=$3
INPUT_3=$4
db2cmd="CALL BACKUP('$INPUT_1', '$INPUT_2', '$INPUT3')"
connect to $Dname
db2 +c -tv "${db2cmd}";>>log_file
}

##### call the above function using.....
ExecuteDB2Proc SAMPLE VALUE1 VALUE2 VALU3
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. How to Post in the The UNIX and Linux Forums

Calling a Sybase Stored procedure from a 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

2. Shell Programming and Scripting

Calling Oracle stored procedure from ksh script

Friends, I'm newbie with ksh so wanting some help.... 1. I'm trying to call oracle stored procedure from ksh script by taking variable value from runtime, feed into script and execute procedure. 2. Put name1 and name2 value from script run replacing $3 & $4 I'm trying to put name1 in... (4 Replies)
Discussion started by: homer4all
4 Replies

3. Shell Programming and Scripting

Run stored procedure from shell script

Hello all, I am trying to run stored procrdure from shell script which takes one argument. And also I want to verify in the script whether the script executed successfully. However the Stored procedure is not running from shell script. Manually if I run it update the data in the table. Can... (29 Replies)
Discussion started by: PriyaSri
29 Replies

4. Shell Programming and Scripting

How to get OUT parameter of a stored procedure in shell script?

I am invoking a SQL script from shell script. This SQL script will invoke a stored procedure(which has the OUT parameter). I want to have the OUT parameter in the shell script as a variable. Is this possible? (6 Replies)
Discussion started by: vel4ever
6 Replies

5. Shell Programming and Scripting

input stored procedure to shell program

Hello, I have to call the stored procedure as argument from the unix shell program. Looks like unix doesnt like, can someone comment pls USERID=scott PASSWD=xxxxxx PLSQLCALL=$2 STDT=`sqlplus /nolog <<END >> $LOGFILE conn ${USERID}/${PASSWD}@${ORACLE_SID} whenever sqlerror exit failure... (9 Replies)
Discussion started by: tvanoop
9 Replies

6. Shell Programming and Scripting

How to execute the stored procedure from shell script

How to execute the stored procedure from shell script and is there any possibility to print the dbms output in a log file. (2 Replies)
Discussion started by: dineshmurs
2 Replies

7. Shell Programming and Scripting

Checking for existence of stored procedure through script

Hi, I have a stored procedure which takes in arguments from my script and deletes rows from a table. Before calling the procedure from the script i want to make sure if the procedure actually exists.If it exists, i want to pass values to the procedure and execute it.if the stored procedure... (3 Replies)
Discussion started by: justchill
3 Replies

8. Shell Programming and Scripting

Need to call stored procedure from unix script

Hi Guys, I have a stored procedure which has 5 out parameters. I need to call the stored procedure from the script. When i use the following in my script, db2 "CALL FCFM.PART_MASTER_TMP($Return_code,$Message,$Message1,$SQL,$Load_count)" >> $LOG_FILE I am getting an error.. Please... (1 Reply)
Discussion started by: mac4rfree
1 Replies

9. Shell Programming and Scripting

Calling stored procedure from shell script

HI, I have a similar problem to thread 18264, only I couldn't get it to work. https://www.unix.com/showthread.php?t=18264 I have a stored procedure which is called by a shell script program. When I run the stored procedure alone or through the shell script, it works fine with output text... (3 Replies)
Discussion started by: dorisw
3 Replies

10. Shell Programming and Scripting

calling stored procedure from shell script.

Hi All, This is a very starnge problem I am having. I have a shell script that calls a stored procedure. Here's my code in shell script: sqlplus "userid/pwd" @file.sql and file.sql has the following statement: exec my_storedProc; Now, when I execute my shell script, nothing... (2 Replies)
Discussion started by: priyamurthy2005
2 Replies
Login or Register to Ask a Question