this question has been discussed many times in the forum..
many newbies, that have never used DB2, and maybe can not read the english doc, do not know that you have to code triple quote..
and we stupid dba still answer these questions...
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
set serveroutput on@
declare l_card int;
declare l_stmt varchar(128);
set l_stmt = 'set ? = (select card from sysibm.systables where name=? and creator=?)';
prepare s_stmt from l_stmt;
for c1 as
select name, creator from sysibm.systables where creator='SYSIBM'
select card into l_card
where name=c1.name and creator=c1.creator;
call dbms_output.put_line(l_card || ' (s) ' || c1.name);
-- dynamic with parameters
execute s_stmt into l_card using c1.name, c1.creator;
call dbms_output.put_line(l_card || ' (d1) ' || c1.name);
-- dynamic w/o parameters
set l_stmt = 'set ? = (select card from sysibm.systables where name=''' || c1.name || ''' and creator=''' || c1.creator ||''')';
prepare s_stmt2 from l_stmt;
execute s_stmt2 into l_card;
call dbms_output.put_line(l_card || ' (d2) ' || c1.name);
BTW, I would not recommend you to use the tables in SYSIBM schema.
Use the correspondent views in the SYSCAT schema instead.
For example, SYSIBM.SYSTABLES -> SYSCAT.TABLES