Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2004
    Posts
    35

    Unanswered: DB2 Passing parameter from os shell windows

    Hi,
    I need to create a batch script that create tablespace and schema , the batch file suppose to pass this 2 parms to an sql file that will create the objects.
    How it can be done?

    10x

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Code:
    #!/bin/sh
    db2 -t <<!eof
    create tablespace $1 managed by system using ('$2');
    commit;
    !eof
    The shell will substitute the values of the command line arguments ($1 and $2) given to the script before passing the strings to db2.

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Oh, it's on Windows... I guess you'll have to install Cygwin :-)

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    But still...
    Code:
    @echo off
    echo create tablespace %1 managed by system using ('%2'); > tmp.sql
    echo commit; >> tmp.sql
    db2 -tf tmp.sql
    if errorlevel 0 del tmp.sql

  5. #5
    Join Date
    Sep 2004
    Posts
    35
    10x that was very helpfull, if i have multi statements i'll have 2 use the echo command or is their another way?

Posting Permissions

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