Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2012
    Posts
    19

    Unanswered: db2set from a batch script

    I'm writing a batch script to restore database on a backup server. I need to set DB2_OVERRIDE_BPF variable since backup server doesn't have enough memory to create original buffer pools. But when I add db2set inside the script I get SQL1024N: There is no connection to a database. If I establish connection to a database (which is odd since DB2_OVERRIDE_BPF is a registry variable and isn't supposed to be defined on a database level) it says that db2set is not a valid CLP command. And I'm stuck here.

    I run the script using: db2cmd db2 -t -f script.db2 -z script.err

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    You have to run it as shell (operating system) script, not as a DB2 script.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Feb 2012
    Posts
    19
    Quote Originally Posted by Marcus_A View Post
    You have to run it as shell (operating system) script, not as a DB2 script.
    Then how can I change this variable from a command script? Or that is impossible?

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    What OS are you using?

    If using Windows, create the following bat file:

    Code:
    db2set DB2_OVERRIDE_BPF=1000 (or whatever) 
    db2cmd db2 -t -f script.db2 -z script.err
    Not sure if that db2set variable requires instance restart to take effect.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  5. #5
    Join Date
    Feb 2012
    Posts
    19
    I'm on Windows. Thanks for quick solution. It apparently works. Sorry for such primitive questions.

  6. #6
    Join Date
    Feb 2012
    Posts
    19
    But can you explain why it doesn't work from inside a script. Documentation says that db2 script can contain db2 commands, db2 system commands, SQL statements and operating system commands. Since db2set is a db2 system command it should work, shouldn't it?

  7. #7
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by Harmont View Post
    But can you explain why it doesn't work from inside a script. Documentation says that db2 script can contain db2 commands, db2 system commands, SQL statements and operating system commands. Since db2set is a db2 system command it should work, shouldn't it?
    DB2 system commands must be submitted at the OS level since they are executable programs. The doc you are looking at must be using the term "db2 script" loosely and not meaning "db2 command script" (which can only contain db2 commands or SQL).
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  8. #8
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by Harmont View Post
    But can you explain why it doesn't work from inside a script. Documentation says that db2 script can contain db2 commands, db2 system commands, SQL statements and operating system commands. Since db2set is a db2 system command it should work, shouldn't it?
    To run an OS command, which db2set is, from a CLP script, prepend it with a "!".

  9. #9
    Join Date
    Feb 2012
    Posts
    19
    Thanks for the tip. I can add here that in case you need to specify flags for command, put it into parentheses. For example:
    Code:
    !(db2set -l)

Posting Permissions

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