We have a stored procedure that dynamically builds a sql statement.
Is there an example of how to get the SP to return the result set of a
dynamically generated sql statement.
here is an oversimplified sql statement - just to prove the point:
set SQLStatement = 'select c1, c2 from syscat.tables ';
set SQLStatement = SQLStatement || 'where other stuff...'
set SQLStatement = SQLStatement || 'UNION select A2, B3 from X where
other stuff...'
--execute immediate SQLStatement;--
PREPARE stmt1 from SQLStatement;
EXECUTE stmt1;
Comment