You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by "Sedillo, Derek (Mission Systems)" <De...@ngc.com> on 2007/04/27 19:25:21 UTC

IJ scripting - parameters or variables?

Hello,

Currently we perform all our Oracle DB builds using SQL scripts.  The
scripts take parameters such as the install directory which varies from
server to server, development vs. production, etc...  

Is there any way to pass in variables to ij SQL scripts or define local
variables?  If not do you have to manually 'hard code' everything in
your scripts?

Here is a code snippet from one of our Oracle build script:

--
-- to use this script:
--    Parameters -
--      1st Param:  INSTALL_DIR
--      2nd Param:  SID_TO_BUILD
--      @build_unclass_db.sql INSTALL_DIR SID_TO_BUILD
--    EXAMPLE:
--    @build_unclass_db.sql ora3 DEV1
--
-- ***************************************************
define INSTALLDIR=/&1/&2
define CUR_SID=&2
define ORACLE_BASE=/&1
PROMPT INSTALLDIR = &INSTALLDIR
PROMPT CUR_SID = &CUR_SID
PROMPT ORACLE_BASE = &ORACLE_BASE
...

Is there any spec on ij scripting syntax?  So far the only documentation
I have discovered is 'very' minimal:
http://db.apache.org/derby/docs/10.2/tools/

Thank you for any help on the matter.

- Derek


Re: IJ scripting - parameters or variables?

Posted by Stanley Bradbury <St...@gmail.com>.
Bryan Pendleton wrote:
>> Is there any way to pass in variables to ij SQL scripts or define local
>> variables?  If not do you have to manually 'hard code' everything in
>> your scripts?
>
> Since IJ scripts are, in the end, just text files, it seems
> like you could use pretty much any scripting language to
> construct your scripts with parameter substitution, then feed
> the results into IJ.
>
> For example, you might investigate Ruby, which is a great scripting 
> language.
>
> thanks,
>
> bryan
>
>
>
Hi Derick -

I believe that what you need can be done by specifying database install 
information on the IJ command line.  This is how I setup my install 
scripts.  If the installation is complex you can wrap the commands in an 
OS script like Bryan suggests or just document the command (gets pretty 
long)  that needs to be typed by the person performing the install.  The 
scripts that IJ reads can only contain IJ commands and standard SQL 
commands, there is no programming API for IJ - Java is the Derby API and 
can do everything IJ can and more.  Here is an example of the IJ command 
line that uses variables to create a DB and specify the install 
information the reads the SQL script 'doDbSetup.sql' and saves the 
output/messages in doDbSetup.log.

 -- variables
DBNAME=MyDB
INSTALLDIR=/usr/derby/databases
DBOPTIONS=;create=true;dataEncryption=true;bootPassword=clo760uds2caPe

-- command line
java -Dij.protocol=jdbc:derby:  
-Dij.database=$INSTALLDIR/$DBNAME$DBOPTIONS org.apache.derby.tools.ij 
<   doDbSetup.sql   >> doDbSetup.log



Re: IJ scripting - parameters or variables?

Posted by Bryan Pendleton <bp...@amberpoint.com>.
> Is there any way to pass in variables to ij SQL scripts or define local
> variables?  If not do you have to manually 'hard code' everything in
> your scripts?

Since IJ scripts are, in the end, just text files, it seems
like you could use pretty much any scripting language to
construct your scripts with parameter substitution, then feed
the results into IJ.

For example, you might investigate Ruby, which is a great scripting language.

thanks,

bryan



RE: IJ scripting - parameters or variables?

Posted by "Sedillo, Derek (Mission Systems)" <De...@ngc.com>.
Anyone out there using scripts? 

-----Original Message-----
From: Sedillo, Derek (Mission Systems) [mailto:Derek.Sedillo@ngc.com] 
Sent: Friday, April 27, 2007 11:25 AM
To: Derby Discussion
Subject: IJ scripting - parameters or variables?

Hello,

Currently we perform all our Oracle DB builds using SQL scripts.  The
scripts take parameters such as the install directory which varies from
server to server, development vs. production, etc...  

Is there any way to pass in variables to ij SQL scripts or define local
variables?  If not do you have to manually 'hard code' everything in
your scripts?

Here is a code snippet from one of our Oracle build script:

--
-- to use this script:
--    Parameters -
--      1st Param:  INSTALL_DIR
--      2nd Param:  SID_TO_BUILD
--      @build_unclass_db.sql INSTALL_DIR SID_TO_BUILD
--    EXAMPLE:
--    @build_unclass_db.sql ora3 DEV1
--
-- ***************************************************
define INSTALLDIR=/&1/&2
define CUR_SID=&2
define ORACLE_BASE=/&1
PROMPT INSTALLDIR = &INSTALLDIR
PROMPT CUR_SID = &CUR_SID
PROMPT ORACLE_BASE = &ORACLE_BASE
...

Is there any spec on ij scripting syntax?  So far the only documentation
I have discovered is 'very' minimal:
http://db.apache.org/derby/docs/10.2/tools/

Thank you for any help on the matter.

- Derek