Basically if you want to pass parameters you need to use a shell script (extension .sh) not a sql file (extension .sql).
Here's an article with explanation and several examples ...
http://www-128.ibm.com/developerworks/db2/library/techarticle/0203yip/0203yip.html
Another approach would be to write a stored procedure .. you can pass parameters on the CALL.
Best, Hal Steiner
-----Original Message-----
From: db2udbdba-ezmlmshield-x29012003.[Email address protected]
To: [Email address protected]
Sent: Tue, 28 Nov 2006 11:26 AM
Subject: ¿execute a script.sql with parameters in db2?
I need please an example to execute a script.sql with parameters in db2.
thank guru.
K=(
Atte...
Daniel Manque P.
Analista de Sistemas.
________________________________
De: hsteiner [mailto:db2udbdba-ezmlmshield-x6028813.[Email address protected]
Enviado el: Mar 28-11-2006 13:09
Para: LazyDBA Discussion
Asunto: Re: connect to db2 for shell unix.
Here is a simple .sh example:
CODE:
#! /usr/bin/ksh
. $HOME/sqllib/db2profile
db2 "connect to DBNAME";
date;
db2 "reorg table SCHEMA.TABLE";
date;
echo "reorg complete";
db2 "terminate";
NOTE: The second line "sources" the db2profile. This might be needed for example
if a job is CRON'ed
Here is something a little more sophisticated - it assumes a connection exists:
#! /usr/bin/ksh
. $HOME/sqllib/db2profile
LOG=/bb/db2/home/mydir/hal/takeover.log
echo "Hal's Takeover Script starting" >> $LOG;
date >> $LOG
status=`db2 activate database DBNAME`;
echo "Activate database - status $status" >> $LOG;
date >> $LOG
status=`db2 takeover hadr on database DBNAME`;
rc=$?
echo "takeover status is $status return code is $rc" >> $LOG;
if [ $rc -ne 0 ]; then
echo "takeover by force" >> $LOG;
status=`db2 takeover hadr on database DBNAME by force`;
echo "Takeover by force issued - status $status" >> $LOG;
fi
date >> $LOG
echo "Hal's Takeover Script complete";
Hope this helps.
Hal Steiner
-----Original Message-----
From: db2udbdba-ezmlmshield-x8907443.[Email address protected]
To: [Email address protected]
Sent: Tue, 28 Nov 2006 9:55 AM
Subject: RE: connect to db2 for shell unix.
Hi gurú...
i need example Execution of script (in terminal unix)...please, please, please
Thank's
pleaseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.
k=(
Atte.
Daniel Manque.
Analista de sistemas.
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
________________________________________________________________________
Check out the new AOL. Most comprehensive set of free safety and security
tools, free access to millions of high-quality videos from across the web, free
AOL Mail and more.
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
________________________________________________________________________
Check out the new AOL. Most comprehensive set of free safety and security tools, free access to millions of high-quality videos from across the web, free AOL Mail and more.
DB2 & UDB email list listserv db2-l LazyDBA home page