Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Unanswered: pass system environment variables into sql script

    Hi, I was wondering how to pass system environment variables into sql script. Basically I have a bat file that setups tablespaces based on project names, and I would like to update my create table sql file to use the tablespaces defined in the bat file. is this possible?

    for example lets say I have this

    setEnv.bat
    set TABLESPACE=ProjectA


    createTable.sql
    CREATE TABLE TEST
    (
    textA VARCHAR(3) NOT NULL,
    textB VARCHAR(3) NOT NULL
    ) IN %TABLESPACE%;

  2. #2
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,369
    Can you pass it as an argument to a shell script. Something like:

    $ more create.table
    db2 connect to sample
    db2 "create table testt (c1 int, c2 int) in $*"


    $ ./create.table userspace1

    Database Connection Information

    Database server = DB2/AIX64 9.7.2
    SQL authorization ID = xxxxxx
    Local database alias = SAMPLE

    DB20000I The SQL command completed successfully.

  3. #3
    Join Date
    Jun 2010
    Posts
    2
    thanks that worked....

    another question how do I import data into a specified table in a table space.

    tried this but no luck
    db2 "import from TAG.ixf of ixf COMMITCOUNT 100 messages TAG.log insert into TAG IN %TABLESPACE%"

  4. #4
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,369
    use import/insert into an existing table without specifying the tablespace or import/create into a new table and specify the tablespace

Tags for this Thread

Posting Permissions

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