Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: How to get the result of an EXECUTE IMMEDIATE command?

$
0
0

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:

 

4.PNG

 

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


Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>