@echo off
rem  (C) COPYRIGHT International Business Machines Corp. 1999, 2000
rem  All Rights Reserved.
rem
rem  US Government Users Restricted Rights - Use, duplication or
rem  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

rem Builds a Java embedded SQL (SQLJ) stored procedure
rem Usage: bldsqljs prog_name [ db_name [ userid password ]]

if "%1" == "" goto error

rem Translate and compile the SQLJ source file
rem and bind the package to the database.
if "%2" == "" goto case1
if "%3" == "" goto case2
if "%4" == "" goto error
goto case3
:case1
   sqlj %1.sqlj 
   db2profc -url=jdbc:db2:sample -prepoptions="package using %1" %1_SJProfile0 
   goto continue
:case2
   sqlj     -url=jdbc:db2:%2 %1.sqlj 
   db2profc -url=jdbc:db2:%2 -prepoptions="package using %1" %1_SJProfile0
   goto continue
:case3
   sqlj     -url=jdbc:db2:%2 -user=%3 -password=%4 %1.sqlj
   db2profc -url=jdbc:db2:%2 -user=%3 -password=%4 -prepoptions="package using %1" %1_SJProfile0
   goto continue
:continue

rem Copy the *.class and *.ser files to the 'function' directory.
copy %1*.class "%DB2PATH%\function"
copy %1*.ser "%DB2PATH%\function"

goto exit

:error
echo Usage: bldsqljs prog_name [ db_name [ userid password ]]

:exit

@echo on