If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Trouble executing sql file from script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-21-08, 12:04
rev1976 rev1976 is offline
Registered User
 
Join Date: Dec 2007
Posts: 78
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
Reply With Quote
  #2 (permalink)  
Old 01-21-08, 13:37
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
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
Reply With Quote
  #3 (permalink)  
Old 01-21-08, 13:43
rev1976 rev1976 is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 01-21-08, 13:50
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
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
Reply With Quote
  #5 (permalink)  
Old 01-21-08, 13:55
rev1976 rev1976 is offline
Registered User
 
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.
Reply With Quote
  #6 (permalink)  
Old 01-21-08, 14:02
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Where is this error appearing? In the *.out files? or on the command line?

Andy
Reply With Quote
  #7 (permalink)  
Old 01-21-08, 14:04
rev1976 rev1976 is offline
Registered User
 
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.
Reply With Quote
  #8 (permalink)  
Old 01-21-08, 14:10
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Can you post a script (just up to the first line that gives the error) and its corresponding out file?

Andy
Reply With Quote
  #9 (permalink)  
Old 01-21-08, 15:07
rev1976 rev1976 is offline
Registered User
 
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.
Reply With Quote
  #10 (permalink)  
Old 01-21-08, 15:10
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Can you post tables.sql and tables.out?

Andy
Reply With Quote
  #11 (permalink)  
Old 01-21-08, 15:20
rev1976 rev1976 is offline
Registered User
 
Join Date: Dec 2007
Posts: 78
Deleted code

Last edited by rev1976; 01-21-08 at 15:58.
Reply With Quote
  #12 (permalink)  
Old 01-21-08, 15:22
rev1976 rev1976 is offline
Registered User
 
Join Date: Dec 2007
Posts: 78
Deleted code

Last edited by rev1976; 01-21-08 at 15:58.
Reply With Quote
  #13 (permalink)  
Old 01-21-08, 15:22
rev1976 rev1976 is offline
Registered User
 
Join Date: Dec 2007
Posts: 78
Deleted code

Last edited by rev1976; 01-21-08 at 15:58.
Reply With Quote
  #14 (permalink)  
Old 01-21-08, 16:00
rev1976 rev1976 is offline
Registered User
 
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
Reply With Quote
  #15 (permalink)  
Old 01-21-08, 17:12
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On