Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

begin declare continue handler for sqlstate '42704' begin /* Ignore */ end@

222 views
Skip to first unread message

gimme_this...@yahoo.com

unread,
Jul 27, 2009, 5:39:35 PM7/27/09
to
I have a script that looks like this:

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.

Serge Rielau

unread,
Jul 27, 2009, 6:04:46 PM7/27/09
to

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

0 new messages