Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2012

    Unanswered: executing multiple scripts.

    hi, i have 100 different scripts which will create 100 tables. how do i run it so that all the 100 scripts run at a single shot.

    i have tried this command: db2 -svtf scriptname.sql.
    And the scriptname is the text document that contains the path of the folder which contains 100 table scripts. I am using db2 v9.7, OS: Windows xp, and i am using clp.

  2. #2
    Join Date
    May 2003
    Create a shell script that reads the directory path and then executes the DB2 command for each file in the path. Contact a shell script expert for assistance on that (not a DB2 question).
    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
    Apr 2012
    Provided Answers: 17
    Here is an easy way to do it.

    If your directory has 100 files that all have the same file-extension (for example *.ddl or *.sql), then you can quickly create a single file and execute that single file.

    This will only work correctly if there are no dependencies between the tables (in other words if the ORDER in which they execute does not matter), and also if there are no *other* files in the same directory that you don't want to include

    To do this (in a db2cwadmin.bat window, or for Windows XP a DB2CMD.EXE window):

    cd your_directory
    copy   /a   *.ddl    all_tables
    db2 -tvf all_tables

    If the ORDER of executing the files is important, you can use the COPY command with the + option to create the new single file with the correct order. For example:
    copy /a  table001.sql+table002.sql+table003.sql    all_tables
    If you don't want to type all the file names: use
    dir /b  *.ddl  >  ddl_file_list
    notepad ddl_file_file   - you can change the order, add + , etc
    Last edited by db2mor; 07-07-12 at 10:36.

Posting Permissions

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