Reputation: 6694
Is it possible to define the type of a variable in a stored procedure dynamically with the type of a column in a table..
I want to set the type of myVar
the type of mytable.mycolumn
DECLARE at_end SMALLINT DEFAULT 0;
DECLARE myVar VARCHAR(21); -- It should be the type of mytable.mycolumn
In Oracle it would be possible with age_of_person mytable.mycolumn%TYPE;
How does it work in DB2 9.7??
Upvotes: 3
Views: 1706
Reputation: 6694
I found the solution.
DECLARE myVar ANCHOR DATA TYPE TO mytable.mycolumn;
Another way is to enable Oracle commands in DB2. It makes possible to use PL-SQL Syntax (i.e. %TYPE
keyword) like in oracle
Upvotes: 2