Hi Sanjay,
Here are complete working .BAT scripts. You may modify these as required.
I may not have understood your exact application, but these scripts can be modified as you need them.
For java, I will take a day or two. ( I did never need java because db2 is so easy to program in every language or script that I just kept writing .bat scripts).
I will post java versions soon. Plz check the attachments.
Version 1 - main_1.bat
Code:
@echo off
set "masterdb=%1"
set "version=%2"
set "poi=%3"
if "%poi%" == "" goto ShowSyntax
if not "%4" == "" goto ShowSyntax
:: we are good to run db2 script now - we will call direct from this bat script
::====================
db2 connect to %masterdb%
if errorlevel 1 exit /b %errorlevel%
db2 echo "database Sucessfully connected"
db2 set current schema=%version%
if errorlevel 1 exit /b %errorlevel%
db2 echo "Schema Set is Done"
db2 echo "Calling function fn_country for %poi%"
db2 call %version%.fn_poi('%poi%',?)
if errorlevel 1 exit /b %errorlevel%
db2 echo "Function executed Sucessfully"
exit /b 0
:ShowSyntax
db2 echo
db2 echo Syntax :
db2 echo %~n0 <db> <ver> <poi>
db2 echo
db2 echo Three parameters exactly, please.
exit /b 5
Version 2- main_2.bat
Code:
@echo off
set "masterdb=%1"
set "version=%2"
set "poi=%3"
if "%poi%" == "" goto ShowSyntax
if not "%4" == "" goto ShowSyntax
:: we are good to run db2 script now - generate the script and call it
::==================== let the script name be main_2.sql
echo connect to %masterdb% >main_2.sql
echo echo database Sucessfully connected >>main_2.sql
echo set current schema=%version% >>main_2.sql
echo echo Schema Set is Done >>main_2.sql
echo echo Calling function fn_country for %poi% >>main_2.sql
echo call %version%.fn_poi('%poi%',?) >>main_2.sql
echo echo Function executed Sucessfully >>main_2.sql
db2 -sf main_2.sql
::------- delete the script - uncomment the line below to delete the sql script
:: del main_2.sql
exit /b 0
:ShowSyntax
db2 echo
db2 echo Syntax :
db2 echo %~n0 <db> <ver> <poi>
db2 echo
db2 echo Three parameters exactly, please.
exit /b 5
Please have a look at produces SQL script in Version 2.
Regards
DBFinder