Code:
Column Type Type
name schema name Length Scale Nulls
------------------------------ --------- ------------------ -------- ----- ------
I SYSIBM INTEGER 4 0 Yes
J SYSIBM INTEGER 4 0 Yes
Code:
create procedure p2(out txt1 char(254))
language sql
begin p1:
declare s1 char(254) ;
declare s2 char(254);
declare exit handler for sqlexception
begin
get diagnostics exception 1 txt1= message_text ;
--set txt1='dd' ;
end ;
set s1='insert into t1 values(1,''d'')' ;
execute immediate s1 ;
set txt1='10' ;
end @
Code:
Value of output parameters
--------------------------
Parameter Name : TXT1
Parameter Value : SQL0408N A value is not compatible with the data type of its assignment target. Target name is "J". SQLSTATE=42821
Return Status = 0
or if you want just the column name, you can use DB2_TOKEN_STRING instead of MESSAGE_TEXT.
Also, you can write different exit handlers for different exceptions. Check the manual for more info