Dynamically determine the type of a variable in stored procedures in DB2

Is it possible to dynamically determine the type of a variable in a stored procedure with a column type in the table.

I want to set a type myVar

like mytable.mycolumn

DECLARE at_end SMALLINT DEFAULT 0;
DECLARE myVar VARCHAR(21); -- It should be the type of mytable.mycolumn

      

In Oracle, this is possible with age_of_person mytable.mycolumn%TYPE;

How does it work in DB2 9.7 ??

+3


source to share


1 answer


I found a solution.

DECLARE myVar ANCHOR DATA TYPE TO mytable.mycolumn;

      



Another way is to include Oracle commands in DB2. This allows the PL-SQL syntax (i.e. Keyword %TYPE

) to be used like in oracle

+2


source







All Articles