RE: How to pass the parameters to a sql at runtime.

RE: How to pass the parameters to a sql at runtime.

 

  

Any idea about this?



-----Original Message-----
From: Jayaprakash.Bandaru
Sent: Monday, August 28, 2006 4:44 PM
To: LazyDBA Discussion
Subject: How to pass the parameters to a sql at runtime.

Hi All,

I need to execute a sql in the shell script. While executing the script,
I need to pass no of days at runtime.

Eg.

This is my backup stus sql file.

more backup_status.sql
select timestampdiff(4,char(timestamp(end_time)-timestamp(start_time)))
as "Duration (min)",
substr(firstlog,1,13) as "Start Log", substr(lastlog,1,13) as
"End Log",
num_tbsps as "No.Of tbspcs",
case(operationType)
when 'F' then 'Offline Full'
when 'N' then 'Online Full'
when 'I' then 'Offline Incremental'
when 'O' then 'Online Incremental'
when 'D' then 'Offline Delta'
when 'E' then 'Online Delta'
else '?'
end as Type,
date(timestamp(end_time)) as "Day Completed",
time(timestamp(end_time)) as "Time Completed", from list_history
where operation = 'B' and
date(timestamp(end_time)) > ( current date - &dd days);

I am executing this in the script,db2 -tf backup_status.sql $1 >
backup_status_db.out.

When I execute backup_status.sh, it is throwing the error:

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

Any suggestions please?

Jayaprakash.



DB2 & UDB email list listserv db2-l LazyDBA home page