Unanswered: How fill the '?' parameter in the sql query
I'm brand new in DB2. I'm trying to create some procedures but I'm failing. The problem is this: I got a table, where there's a specific SQL to be run with a parameter '?' which has to be filled:
table name: TASKS
1 insert into students (firstName, lastName, checkId) select firstName, lastName, ? from kids where age = 18
2 insert into students (firstName, lastName, checkId) select firstName, lastName, ? from kids where sex = 'female'
3 insert into students (firstName, lastName, checkId) select firstName, lastName, ? from kids where grade = 'b+'
and so on.
The exercise is:
1. select the ID and SQL from above table;
2. Run the selected SQL but instead of the parameter '?' in the SQL set the value of ID.
This is what I got:
declare idNumber INTEGER;
for std as
select ID idValue, SQL sqltext from TASKS
set idNumber = idvalue;
execute immediate sqltext using idNumber;
But i'm still failing. I tried: "execute immediate sqltext :idNumber" and so on, but it doesn't work. I've read about passing variables into sql and parameters '?' but no solution works. I'd be happy anyone explain what's wrong.
Best Regards, Guy Przytula
Database Software Consultant
Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
Information Server Datastage Certified http://www.infocura.be