I have a DB2 Stored Procedure that takes input parameter and returns me result set (5 columns ) from cursor. I am able to connect to DB2 Server from my UNIX BOX and run the stored procedure and I get the resultset on my screen. Below is what I do:-
source /mycomp/thisproj/proj/Ascential/DataStage/DSEngine/dsenv
~db2inst1/sqllib/bin/db2
Connect to db2dsn user DB2SPUSER using pass@#45;
CALL SYSPROC.MYSTPROC(?,?,?,?,'U');
I want to write a SHELL SCRIPT that I want to execute and it should save the output data into a TEXT file on my UNIX Server
(1) How do I write a SHELL SCRIPT to do the above steps.
(2) How do I save all my output data into a TEXT file that I will read in my
next job
Shell Script to execute DB2 Stored Procedure
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 71
- Joined: Mon Jul 09, 2007 1:12 pm
-
- Participant
- Posts: 334
- Joined: Fri Dec 01, 2006 5:17 am
- Location: Texas
Hi,
We have implemented the same thing...but our database is Oracle.
Following is the sample script which we use to connect to Oracle and which will save the output in .txt file.
The output of the file is :
The file 1.txt can be edited as per the requirement.I hope you will get some idea ... ![Smile :)](./images/smilies/icon_smile.gif)
We have implemented the same thing...but our database is Oracle.
Following is the sample script which we use to connect to Oracle and which will save the output in .txt file.
Code: Select all
cat 1.sh
sqlplus username/password@sid <<EOF
spool 1.txt
select sysdate from dual;
exit;
spool off
EOF
Code: Select all
cat 1.txt
SQL> select sysdate from dual;
SYSDATE
---------------
14-MAY-08
SQL> exit;
![Smile :)](./images/smilies/icon_smile.gif)
http://findingjobsindatastage.blogspot.com/
Theory is when you know all and nothing works. Practice is when all works and nobody knows why. In this case we have put together theory and practice: nothing works. and nobody knows why! (Albert Einstein)
Theory is when you know all and nothing works. Practice is when all works and nobody knows why. In this case we have put together theory and practice: nothing works. and nobody knows why! (Albert Einstein)