Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2008
    Posts
    2

    Unanswered: 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

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  3. #3
    Join Date
    Dec 2008
    Posts
    2
    Thanks Andy,

    I followed the first method and it worked...

    Neeraj

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •