If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > how to pass variables into .sql file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-07-08, 06:26
tegiac tegiac is offline
Registered User
 
Join Date: Aug 2008
Posts: 2
how to pass variables into .sql file

Dear All,

I'm trying to write a batch file executing some sql statements (drop database, create database ...) in DB2 and the database name is a parameter.

1. I have 2 files: run.bat and script.sql
---run.bat--
db2cmd db2 -f script.sql

---script.sql---
drop database mydb
create database mydb
connect to mydb user myuser using mypwd
...

How can I pass variable (mydb...) into script.sql from run.bat?

2. I include the sql statements within run.bat like below
---run.bat---
db2cmd -c -w -i db2 drop database mydb db2 create database mydb ...

But it seems not able to execute more than 1 sql statement. How can I run many sql statements?

I'm using DB2 8.1

Thanks for your reading
Reply With Quote
  #2 (permalink)  
Old 08-07-08, 06:58
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
check this out: dos scripits for db2
there is explanation how to have only one DB2 file on Windows.
Hope this helps,
Grofaty
Reply With Quote
  #3 (permalink)  
Old 08-08-08, 05:03
tegiac tegiac is offline
Registered User
 
Join Date: Aug 2008
Posts: 2
Dear grofaty,

Thanks so much for the link, it really helps me

tegiac
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On