I'm not getting the syntax for declaring a continue handler.
I have:
set path sysibm,sysfun,sysproc,sysibmadm@
begin declare continue handler for sqlstate '42704'
begin /* Ignore */ end@
alter table can drop constraint can_fk2@
end
Which results in this:
begin declare continue handler for sqlstate '42704' begin /* Ignore */
end
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0104N An unexpected token "declare" was found following "begin
".
Expected tokens may include: "JOIN <joined_table>". SQLSTATE=42601
Thanks.
Semicolons are used within SQL PL to delimit statements.
Also I don't think you can do a straight alter table within a compound.
You need to go through dynamic SQL.
In DB2 9.7 you should be able to use the string directly:
EXECUTE IMMEDIATE ' ...';
begin
declare txt VARCHAR(1000) DEFAULT
'alter table can drop constraint can_fk2';
declare continue handler for sqlstate '42704'
begin /* Ignore */ end;
EXECUTE IMMEDIATE txt;
end@
--
Serge Rielau
SQL Architect DB2 for LUW
IBM Toronto Lab