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 > Running Db2 script from db2 prompt on Linux

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-02-08, 07:46
neeraj_tri15 neeraj_tri15 is offline
Registered User
 
Join Date: Dec 2008
Posts: 2
Running Db2 script from db2 prompt on Linux

Hi All,

I have written a db2 scripts and running that on Linux using the below command

$ db2 -td@ -vf Script..sql

Below is the sample Script.

--===============
CONNECT TO database USER user1 Using passwd @

SQL STATEMENT @
SQL STATEMENT @
SQL STATEMENT @

--===================

When I need to run this script on three different databases DB1, DB2 and DB3, I am updating the first line of the script every time, to run it on another database.

Is there any way to run the db2 script after logging into the db2 prompt (as in Oracle) so that script update will not be required while running it on another Database?

Any help is appreciated.

Neeraj
Reply With Quote
  #2 (permalink)  
Old 12-02-08, 08:17
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Yes.

You can either remove the connect statement and connect to each database before running the script. Or you can write it as a bash script.

Andy
Reply With Quote
  #3 (permalink)  
Old 12-02-08, 09:02
neeraj_tri15 neeraj_tri15 is offline
Registered User
 
Join Date: Dec 2008
Posts: 2
Thanks Andy,

I followed the first method and it worked...

Neeraj
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