is it is it possible to display contents of a table through stored procedure?

Database
Enthusiast

is it is it possible to display contents of a table through stored procedure?

Hello everyone,
is it is it possible to display contents of a table through stored procedure?If yes then can some one provide me with the syntax

appreciate your help

Thanks
Regards
2 REPLIES
Enthusiast

Re: is it is it possible to display contents of a table through stored procedure?

I need to pass the table name as a parameter to the stored procedure
Junior Contributor

Re: is it is it possible to display contents of a table through stored procedure?

You can't return an answerset through a SP, just a single line using SELECT INTO.

I don't understand, why you ever want to do that, but you could use dynamic sql within your SP, e.g.:

create procedure foo (myparam varchar(30);
begin
call dbc.sysexecsql(
'create volatile table bar as (select * from ' || :myparam
|| ') with data on commit preserve rows;')
end;

call foo('blabla');
select * from bar;

Dieter