Results 1 to 4 of 4
  1. #1
    Join Date
    May 2011
    Posts
    15

    Unanswered: how to run a sql file by calling from another sql file

    Hi all,

    I am writing one sql script where i am writing some db2 commands like connect ,select etc.

    but I have to store output of select command inside another file and I want to execute the file from my script .

    so please anyone tell me how to call another .sql file from a script on db2 command line.

    I am using the command db2 -vtf filename to execute the file from db2 command window. but it is giving error when i trying to write the same cmd in file.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    You cannot do what you want. The closest thing to that would be to invoke a new instance of CLP from within your script:
    Code:
    !db2 -vtf newscript.sql
    Be aware that it will create a new execution environment, meaning, in particular, that you will have to create a new connection.

  3. #3
    Join Date
    Dec 2008
    Location
    Toronto, Canada
    Posts
    399
    you can not. you have 2 options:

    1. put it in a script so you can call it from another script
    just add 'db2 -<option> to your sql command.

    2. put it in an sql file and call it from a script
    for example: db2 -tvf file.sql
    DB2 9.5/9.7 on Unix/AIX 6.1/Linux

  4. #4
    Join Date
    May 2011
    Posts
    15

    running sql script

    Thanks all,

    I did it by creating a batch file and I put db2 commands inside it.

    and run it from db2 command window.

    thanks for your guidence....

Posting Permissions

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