Skip to Content
-2

EXIT WHEN KABIL_KEY%NOTFOUND equivalent in SAP HANA

Dec 14, 2017 at 08:04 AM

37

avatar image

Hi Experts,

Currently I'm working on a project to convert Oracle Procedure to HANA Procedures.

In Oracle procedure:

CURSOR KABIL_KEY IS
  SELECT C_YEAR_No, MONTH_No, MIN(T_KEY) AS START_DATE_KEY, MAX(T_KEY) AS END_DATE_KEY
  FROM DW.T_DIM D
  WHERE T_KEY BETWEEN 19990101 AND 20081231
  GROUP BY C_YEAR_No, MONTH_No
  ORDER BY C_YEAR_No, MONTH_No;
K_ROW  KABIL_KEY%ROWTYPE;
BEGIN  ----start of the  procedure
  IF NOT KABIL_KEY%ISOPEN THEN
    OPEN KABIL_KEY;
  END IF;
  LOOP
       FETCH KABIL_KEY INTO M_ROW;
     EXIT WHEN KABIL_KEY%NOTFOUND;

Here I, convert maximum of the above syntax to HANA:

 EXIT WHEN MONTH_KEY%NOTFOUND;	

i dont know what to do the above staement and how to convert this to hana.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Lars Breddemann
Dec 14, 2017 at 10:55 PM
0

The

EXIT WHEN ...%NOTFOUND 

Is simply the end condition for the loop you use to read all data from the cursor.

HANA provides native cursor iteration. Please check the SQLScript developer documentation for the syntax.

FOR curr IN cursor LOOP...END LOOP;
Share
10 |10000 characters needed characters left characters exceeded