In oracle I have a great tool which is retrieving result from dynamic executions.
declare
v_sql varchar2(100);
v_count number;
begin
v_sql := 'select count(*) from dual';
EXECUTE IMMEDIATE v_sql INTO v_count;
end;
In SAP HANA such feature does not exist.
What can we do?
CREATE COLUMN TABLE TEMP_RESULTS (
"ID" INTEGER CS_INT NOT NULL ,
"SQL_TEXT" NVARCHAR(5000),
"NUM_RESULT" INTEGER CS_INT,
"CHR_RESULT" NVARCHAR(5000),
PRIMARY KEY ("ID")
) ;
create sequence temp_result_id starting with 1 ;
Then the usage code
begin
declare v_id integer;
declare v_sql varchar(100);
select temp_result_id.nextval into v_id from dummy;
v_sql := 'insert into TEMP_RESULTS(id, num_result) select ' || v_id || ', count(*) from dummy';
execute immediate v_sql;
select num_result into v_count from TEMP_RESULTS where id = v_id;
end;
Nessun commento:
Posta un commento