How to get variable value from inside a stored procedure in DB2?
Posted
by Sylvia
on Stack Overflow
See other posts from Stack Overflow
or by Sylvia
Published on 2010-03-22T18:12:05Z
Indexed on
2010/03/22
20:41 UTC
Read the original article
Hit count: 157
db2
This seems like it should be very easy...anyway, it is in MS SQL Server
In a DB2 stored procedure, how can I just get the value of a variable? Say I have the following stored procedure:
CREATE PROCEDURE etl.TestABC(
)
LANGUAGE SQL
BEGIN
declare Stmt varchar(2048);
set Stmt = 'this is a test';
-- print Stmt;
-- select Stmt;
return 0;
END @
I'd like to print out the value of Stmt after I set it. Print doesn't work, select doesn't work. Somebody said I have to insert it to a table first, and then get it after I run the stored procedure. Is this really necessary?
Thanks, Sylvia
EDIT: I should have made clearer that I want to see the value of Stmt each time after I set it, and I may need to set it multiple times within the same stored procedure.
© Stack Overflow or respective owner