Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

"After Update of Attribute_name on Table_name " trigger not working properly

$
0
0

Hi All,

 

  • Trigger for  "After Update of Attribute_name on Table_name"
  • Objective : Fire trigger only when update on single attribute (column), not for all attributes.
  • It works fine in Oracle, PostgreSQL but not working properly in HANA.
  • In HANA it fire on every attribute of table, instead of specified (e.g. region in following script)

 

CREATE TABLE salestest (region VARCHAR(100), product VARCHAR(100), amount INTEGER);

CREATE TABLE salestest_dummy (region VARCHAR(100), product VARCHAR(100), amount INTEGER);

 

insert into  salestest (region, product, amount) values('IN', 'cold coffee', 10);

insert into  salestest (region, product, amount) values('US', 'cold coffee', 20);

 

select * from salestest; // Display 2 rows

select * from  salestest_dummy;// Display 0 rows

 

CREATE  TRIGGER salestest_after_update

AFTER UPDATE of region  ON salestest   FOR EACH ROW

BEGIN

   INSERT INTO salestest_dummy (region, product, amount )

                        VALUES ('TESTREGION','TEA', 10);

END;

 

update salestest set region= 'Dummy' where amount=10;// trigger work as per need

 

select * from  salestest_dummy ;// Display 1 rows, correct here

 

update salestest set product= 'Coffee' where amount=10; //trigger not work properly, it insert new row to salestest_dummy

 

select * from  salestest_dummy ;// Display 2 rows, wrong here

 

 

Is it any mistake I did? or any workaround for above script?

 

Thanks,

Somnath A. Kadam


Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>