I have two example tables:
TABLE1:
ID | COLUMN_B| COLUMN_C
_________|_________|_________
1 | 0 | 1
________|_________|_________
2 | 0 | 1
________|_________|_________
3 | 0 | 1
TABLE2:
ID | COLUMN_E| COLUMN_F
________|_________|________
1 | Y | X
________|_________|_________
2 | Y | X
________|_________|_________
3 | Y | X
What I would like to do is to write a trigger on Hana Studio using SQL Script to update column E from table 2 when column B from table 1 is updated to a specific value (let's say, 100). Rows from table 1 are referenced in table 2 with the first column (ID).
I wrote the following code:
create trigger "UPDATE_TABLES"
after update of "COLUMN_B" on "TABLE1"
referencing new row as new, old row as old
for each row
begin
update "TABLE2"
set "COLUMN_E" = 'my new value'
where :old."COLUMN_B" = '100' and "TABLE1"."ID" = :old."ID";
end;
When I set TABLE1.COLUMN_B on row 1 to 100, I expect the code to change TABLE2.COLUMN_E to "my new value" on row 1, but nothing happens. Could anyone point what exactly I am doing wrong here?