View Single Post

   
  #4 (permalink)  
Old 02-27-2008, 08:38 AM
Knut Stolze
 
Posts: n/a
Default Re: Variable in SQL-Script

Stefan wrote:

> Hi Knut,
> thank you for your answer.
> I'm a db2 beginner, so I have some problems with your answer.
> My script is called like this:
> su -root -c "db2 -tvf test.sql"
> In the SQL-Script test.sql are about 10 sql-statements.
>
> I think (2) sounds quit easy, but do you have a small example?


I would do this:

su -root -c "my_db2_script"

The content of "my_db2_script" would be:
------------------snip--------------------------
#!/bin/sh

VAR1=...
VAR2=...

db2 "connect to database"
db2 "first sql statement using ${VAR1}"
db2 "second sql statement"
db2 "another sql statement using ${VAR2}"
db2 "connect reset"

------------------snip--------------------------

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Reply With Quote