cancel
Showing results for 
Search instead for 
Did you mean: 

Recursive table function in HANA SQL script

Rushikesh_Yeole
Contributor
0 Kudos

Dear all,

I am trying to call table function in same function. I am getting error as

Dependent object not found: SqlScript; SYSTEM.public::ZCO_TF_STDCOST_SUB: symbol not found. I tried to search for workarounds. Could you please suggest/ or any other way ? Attaching code snippets below.

FUNCTION "SYSTEM"."public::ZCO_TF_STDCOST_SUB" ( in IT_INPUT table ( ...) ,IN lv_matnr varchar(40))
RETURNS table (...)
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
READS SQL DATA
AS BEGIN

declare cur_ident3 varchar(20);
declare material varchar(40);

DECLARE CURSOR c_cursor3 (cur_ident3 varchar(20)) FOR select *
from :IT_INPUT ;


lt_output = select * FROM "Calc_view" LIMIT 0;
material = :lv_matnr;

for cur_row as c_cursor3(cur_ident3)
do
if cur_row.matnr_1 >= 000000004000000000 and cur_row.matnr_1 <= 000000004000000999 then

lt_temp = select query;

if ::rowcount > 0 then
lt_output = SELECT * FROM "SYSTEM"."public::ZCO_TF_STDCOST_SUB"(:lt_temp, :material) ;
else
lt_output = ce_union_all( :lt_output, :it_input[cur_ident3]) ;
end if;
else
lt_output = ce_union_all( :lt_output, :it_input[cur_ident3]) ;
end if;

END FOR ;

Accepted Solutions (1)

Accepted Solutions (1)

lbreddemann
Active Contributor
0 Kudos

Hmm... is there anything not really way off with this code snippet?

Why don't you just verbally describe what you try to achieve here, since this code is not speaking for itself..

Looping over input tables to select data in a range? Is that a custom way of JOINing?

Using CE-operator for glueing result sets together ... !?

And to answer the question: no, recursive calls are not supported. Replace it with iteration if you must; I've got the feeling you really don't need to, though.

Rushikesh_Yeole
Contributor
0 Kudos

Thanks..I have not shared complete code due to other reasons. I will try to achieve this by using JOIN and WHile loop.

Answers (0)