I know the post is already answered but just want to share that if you want to save the results of the execute immediate statement in a temporary variable, then you can use temporary table like this below,
create type tt_abc as table (count_records integer );
drop procedure ABC; create procedure ABC (in v_table nvarchar(100),out v_count tt_abc) LANGUAGE SQLSCRIPT SQL SECURITY DEFINER DEFAULT SCHEMA LTANGUDU AS begin create local temporary table #temp_abc (count_records integer ); execute immediate 'insert into #temp_abc (select count(*) from '||:v_table ||')'; v_count = select * from #temp_abc; drop table #temp_abc; end;
Output:
PS: for the use case you shared above, there is no need to use dynamic sql , instead you could have used system tables like CS_TABLES, but nevertheless never knew what is the exact use case you are working on so just posted with dynamic SQL and this proc can be called from XSJS
Regards,
Krishna Tangudu