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 > Execute filename.sql with variables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-05-04, 12:30
Sophie Hsiao Sophie Hsiao is offline
Registered User
 
Join Date: Nov 2003
Location: New York
Posts: 14
Angry Execute filename.sql with variables

Hi all,

Dose anybody know how to execute filename.sql with variables ?

We usually execute filename.sql by command, db2 -vtf filename.sql; however, i want to bring variables into filename.sql for the name of database when connecting database, for example,

connect to %dbname

Well, I cound not find any info in command reference.

Please also give me a brife example.

Thank you so much !!

Sophie
Reply With Quote
  #2 (permalink)  
Old 04-05-04, 13:50
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Execute filename.sql with variables

This is not possible in a db2 script AFAIK ...

But you can do shell scripting or windows batch files to accompolish this ..

Eg:

#!/bin/ksh
connect to $1

HTH

Sathyaram
Quote:
Originally posted by Sophie Hsiao
Hi all,

Dose anybody know how to execute filename.sql with variables ?

We usually execute filename.sql by command, db2 -vtf filename.sql; however, i want to bring variables into filename.sql for the name of database when connecting database, for example,

connect to %dbname

Well, I cound not find any info in command reference.

Please also give me a brife example.

Thank you so much !!

Sophie
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 04-05-04, 14:28
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Re: Execute filename.sql with variables

Quote:
Originally posted by sathyaram_s

Eg:

#!/bin/ksh
connect to $1
You probably meant:

#!/bin/ksh
db2 connect to $1
Reply With Quote
  #4 (permalink)  
Old 04-05-04, 15:15
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Execute filename.sql with variables

Thanks Nick, for point out ...

Cheers
Sathyaram

Quote:
Originally posted by n_i
You probably meant:

#!/bin/ksh
db2 connect to $1
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 04-06-04, 12:33
Sophie Hsiao Sophie Hsiao is offline
Registered User
 
Join Date: Nov 2003
Location: New York
Posts: 14
Re: Execute filename.sql with variables

Thanks both anyway !!

Sophie

Quote:
Originally posted by sathyaram_s
Thanks Nick, for point out ...

Cheers
Sathyaram
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