Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    Dec 2007
    Posts
    78

    Unanswered: Trouble executing sql file from script

    Hi there,

    I'm trying to execute the following sql file in my bash script

    db2 -tf tables.sql >> createdb.log
    db2 -tf foreign.sql >> createdb.log
    db2 -tf indexes.sql>> createdb.log
    db2 -tf data.sql>> createdb.log
    db2 -td@ -f reqdelproj_block.sql>> createdb.log
    db2 -td@ -f rqprojlock_delete.sql>> createdb.log
    db2 -td@ -f rqprojlock_insert.sql>> createdb.log
    db2 -td@ -f rqdrop_view.sql >> createdb.log
    db2 -td@ -f rqdrop_views.sql >> createdb.log
    db2 -td@ -f rqdelete_project.sql >> createdb.log

    The script executes with no error message but when i check the log i see the following:

    DB21004E You cannot specify both an input file and a command when invoking
    the Command Line Processor.

    for all the sql calls. Doesn't look like it ran any of my files. Can anyone help please? Thanks in advance

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    First what is the DB2 version and OS?

    Try running the commands like this in the script

    db2 -tvsf sql_file -z output file

    You will need to have a separate output file for each sql file but that should not be a problem.

    Andy

  3. #3
    Join Date
    Dec 2007
    Posts
    78
    I'm running DB2 v9.0 on Linux on intel.

    so the script would look like this:

    db2 -tvsf tables.sql -z output.txt

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Yes, but more like this so it is easier to figure out what happened.

    db2 -tvsf tables.sql -z tables.out
    db2 -tvsf foreign.sql -z foreign.out
    ...

    Andy

  5. #5
    Join Date
    Dec 2007
    Posts
    78
    It's still giving me the same error message
    DB21004E You cannot specify both an input file and a command when invoking
    the Command Line Processor.

    This sql is a series of CREATE statements.

  6. #6
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Where is this error appearing? In the *.out files? or on the command line?

    Andy

  7. #7
    Join Date
    Dec 2007
    Posts
    78
    The script runs fine but when i check the out file that's where the error message is. When i logon to DB2 and do LIST TABLES i don't see any of the tables that were suppose to be created.

  8. #8
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Can you post a script (just up to the first line that gives the error) and its corresponding out file?

    Andy

  9. #9
    Join Date
    Dec 2007
    Posts
    78
    Well i'm executing this in the script

    db2 -tvsf tables.sql -z tables.out

    And the out file is giving me this message:

    DB21004E You cannot specify both an input file and a command when invoking
    the Command Line Processor.

  10. #10
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Can you post tables.sql and tables.out?

    Andy

  11. #11
    Join Date
    Dec 2007
    Posts
    78
    Deleted code
    Last edited by rev1976; 01-21-08 at 16:58.

  12. #12
    Join Date
    Dec 2007
    Posts
    78
    Deleted code
    Last edited by rev1976; 01-21-08 at 16:58.

  13. #13
    Join Date
    Dec 2007
    Posts
    78
    Deleted code
    Last edited by rev1976; 01-21-08 at 16:58.

  14. #14
    Join Date
    Dec 2007
    Posts
    78
    It looks like it doesn't like -f (passing an input file) within a command line. I tried to take it out and it's complaining that an error occurred while accessing the file

  15. #15
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    I have scripts that look like that and they work fine. Please post:

    1) the entire script
    2) how you are executing the script
    3) contents of tables.sql
    4) contents of tables.out

    Andy

Posting Permissions

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