Hi Experts,
I have a very simple question. Your response is highly appreciated. I am new to HANA and started learning SQL Script a few weeks ago.
I am using the below code...
I get this error : "return result set from select stmt exist when result view is defined: line 20 col 37 (at pos 505)". It has to do with o1. But I am not sure where I should put it after the begin statement.
create procedure CATEGORY3PROC(OUT o1 CATEGORY3TAB) language sqlscript sql security invoker reads sql data
with result view CATEGORY3 as c_country nvarchar(20):=''
;
/*c_cat_desc nvarchar(20):=''
;*/
cursor v_country(c_country nvarchar(20)) for select
LAND2
from "_SYS_BIC"."GSA_TEST/***"
group by LAND2
;
/*cursor v_cat_desc(c_cat_desc nvarchar(20)) for select
top 5 WGBEZ_2
from "_SYS_BIC"."GSA_TEST/***"
where LAND2 = :c_country
group by WGBEZ_2
;*/
begin
for ctry as v_country(c_country) do(select
WGBEZ_2,
LAND2,
AP_YEAR,
sum(DMBE2) as DMBE2
from "_SYS_BIC"."GSA_TEST/***"
where LAND2 = ctry.LAND2
and WGBEZ_2 in (select
top 5 WGBEZ_2
from "_SYS_BIC"."GSA_TEST/***"
where LAND2 = ctry.LAND2
group by WGBEZ_2
order by sum(DMBE2) desc)
group by WGBEZ_2,
LAND2,
AP_YEAR
order by sum(DMBE2) desc)
union all (select
'OTHER' as WGBEZ_2,
LAND2,
AP_YEAR,
sum(DMBE2) as DMBE2
from "_SYS_BIC"."GSA_TEST/***"
where LAND2 = ctry.LAND2
and WGBEZ_2 not in (select
top 5 WGBEZ_2
from "_SYS_BIC"."GSA_TEST/***"
where LAND2 = ctry.LAND2
group by WGBEZ_2
order by sum(DMBE2) desc)
group by WGBEZ_2,
LAND2,
AP_YEAR
order by sum(DMBE2) desc)
;
end for
;
end