i am trying to write a stored proceduer in HANA DB, where I can identify the delta records from an Table A (SAP Table PROJ for eg.) and load in Table B (copied the structure of Table A but without data) only the changed records. The procedure must use a field in the Table A (for example Changed Date(AEDAT) or something similiar) and based on that, should identify any new data and load it to the Table B.
I have written the following the script but I guess this is not really fullfilling my requirements. Do you have any suggestion what should I add to my script so that it works like supposed:
PROCEDURE "USER1"."TEST.Test::Deltachangesnew" ( IN IV_MANDT NVARCHAR(3), IN IV_PSPNR NVARCHAR(8), IN IV_AEDAT NVARCHAR (8), OUT ET_CHANGE TABLE ( PSPNR NVARCHAR(8), AEDAT NVARCHAR(8), CHNGDAT NVARCHAR (8))) LANGUAGE SQLSCRIPT SQL SECURITY INVOKER READS SQL DATA AS BEGIN DECLARE filterDate NVARCHAR (8) := 'current_date'; ET_CHANGE = SELECT PSPNR, AEDAT, (filterDate - AEDAT) AS CHNGDAT FROM PROJTEST WHERE MANDT = :IV_MANDT AND PSPNR = :IV_PSPNR AND AEDAT = :IV_AEDAT GROUP BY PSPNR, AEDAT; END; Thanks, Regys