Posts

Showing posts from December, 2021

SAP HANA 2.0 - Database Procedures - Snippets

DATABASE PROCEDURE USING 'FOR' TO CREATE A TABLE & USAGE OF EXIT HANDLER: CREATE PROCEDURE ZAG_FOR_001 (out count1 integer)  LANGUAGE SQLSCRIPT DEFAULT SCHEMA "<ENTER_SCHEMA>" AS BEGIN DECLARE i INTEGER = 0; BEGIN DECLARE EXIT HANDLER FOR SQL_ERROR_CODE 288 DROP TABLE ZAG_EMP_001; CREATE COLUMN TABLE zag_emp_001 ( empid integer, empname varchar(20), primary key(empid) ); END; FOR i in 1..10 DO  INSERT INTO zag_emp_001 VALUES (:i, 'Employee: ' || :i);  END FOR; count1 = i; select count(*) into count1 from <ENTER.SCHEMA>.zag_emp_001; END; DATABASE PROCEDURE USING CURSOR: CREATE OR REPLACE PROCEDURE ZAG_CURSOR_001(OUT ev_matnr varchar(40)) LANGUAGE SQLSCRIPT DEFAULT SCHEMA "UMAMAHESWARA" AS BEGIN DECLARE lv_matnr varchar(40); DECLARE CURSOR c1 FOR SELECT MATNR FROM SAPHANADB.MARA; OPEN c1; FETCH c1 INTO lv_matnr; select lv_matnr into ev_matnr from dummy; CLOSE c1; END; DATABASE PROCEDURE USING INLINE TABLE DECLARATION: CREATE PROCEDURE Z...