Search code examples
sqltriggersinserthana

SAP HANA - Trigger Insert into new table when old table has an insert


I'm trying to create a trigger that will insert all new entries from table_A into table_B under another schema (Exact definition for both tables).

Table_A receives thousands of inserts every time, so the trigger should insert only new inserted rows data, and don't include old ones every time.

Found couple of solution for SQL SERVER, none of it works for SAP HANA.

Thank you.


Solution

  • Make 2 Procedures Proc1 takes insert for the old table and proc2 for the new table. Call proc2 from proc1 with the new values in cursor. For getting the new entries make sure the table has a time stamp field (ex- CREATED_AT), store the last value inserted in a variable and then after update fetch using the variable and pass to proc2.

    Let me know if you need code for the same