1

When creating a row-wise trigger in SAP HANA, a reference to a Row type variable can be obtained. E.g. in the example below :new_row and :old_row are row type variables.

create trigger test_trigger
    after insert on test_table
    referencing new row new_row, old row old_row
    for each row
begin

I am attempting to serialize or convert the Row type variable values to a string or binary type of object. I have not been able to find a way of doing this directly. I.e.

INSERT INTO result_table(row_data) VALUES (<somehow serialize :new_row>);

As an alternative, I could iterate over the column values in the row (:new_row) and convert each of them into a string/binary value in turn, but I couldn't find a way of doing this either.

Note, this has to happen inside the trigger, and as such, Dynamic SQL is not an option as it is not support inside a trigger with SAP HANA.

Is this possible at all?

avanwyk
  • 700
  • 6
  • 13
  • What is the purpose of storing all columns in a combined single column? – Lars Br. Sep 06 '21 at 21:27
  • A single column isn't strictly speaking necessary. However, we would either want to keep the schema for the `result_table` the same, or update it automatically if the row's structure was changed. – avanwyk Sep 08 '21 at 09:40
  • What result table? If the gets changed, you could create a view that transforms the data accordingly to produce an unchanged result structure - that view however needs to be changed together with the Schema change. – Lars Br. Sep 08 '21 at 09:44

0 Answers0