Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB21004E error when trying to pass a parameter to an sql script

Status
Not open for further replies.

DrSmyth

Technical User
Jul 16, 2003
557
GB
HI,
I'm trying to pass parameters from a shell script to an SQL file.
Here's my shell script:
Code:
for TAB_NAME in INX_CDM_DREPORT_DATES INX_CDM_PDBAND
do
echo "Selecting from table $TAB_NAME"
db2 -tvf /gcdm/dev/scripts/ControlMScripts/dailyMI/andytemp/sample.sql $TAB_NAME
done
And here's the SQL file:
Code:
select * from '#TAB_NAM#' with ur

when i run the shell script i get this error:

Selecting from table INX_CDM_DREPORT_DATES
DB21004E You cannot specify both an input file and a command when invoking
the Command Line Processor.
Selecting from table INX_CDM_PDBAND
DB21004E You cannot specify both an input file and a command when invoking
the Command Line Processor.

I'm not sure why i'm getting this error, is it because I can't specify the parameters in the same script that i'm using to run the sql? I'm a bit new to this scripting malarky so am really struggling to get my head around the issue.

Thanks
 
It's OK, I now have a solution. Instead of passing parameter to the sql file, I sed the parameter into a temp sql file and run that:
Code:
sed -e s?#TAB_NAME#?$TAB_NAME?g /gcdm/dev/scripts/ControlMScripts/dailyMI/andytemp/sample.sql > sample_temp.sql
db2 -tvf sample_temp.sql

Works fine now....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top