How do you kick off a DB2 Script in AIX ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pulsar
    New Member
    • Sep 2007
    • 1

    How do you kick off a DB2 Script in AIX ?

    I'm new to using DB2 from AIX, and need to run a series of EXPORT commands of the form EXPORT TO /dir/file1.txt OF DEL MESSAGES /dir/file1.msg SELECT * FROM <TABLE> WHERE <CLAUSE>

    I would like to be able to create a single script that houses all the EXPORT commands and then invoke DB2 from the command line to run these one after then other.

    Can anyone help me with how this is done ?

    Thanks,

    Prem Isaac
  • dewa81
    New Member
    • Jul 2007
    • 14

    #2
    CONNECT TO <dbname>user <userid> using <'password'>;
    EXPORT TO /dir/file1.txt OF DEL MESSAGES /dir/file1.msg SELECT * FROM <TABLE> WHERE <CLAUSE>;
    <next export command>
    ..
    .
    .
    .
    .
    .
    commit;
    CONNECT RESET;

    Comment

    • docdiesel
      Recognized Expert Contributor
      • Aug 2007
      • 297

      #3
      Hi,

      or use a shell script:
      Code:
      db2 connect to mydb
      for var_mytable in "table1 table2 table3"
      do
        db2 "export to ${var_mytable}.txt of del  select * from myschema.${var_mytable} ..."
      done
      db2 connect reset
      Regards, Bernd

      Comment

      Working...