![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a table something like this.... table Alarm( AlarmId integer, AlarmName varchar, Sentflag smallint, AckFlag smallint, RTNFlag smallint, AutoRTNFlag smallint, cookie long); |
|
I am trying to write a trigger on this table for insert and update operations. In the above table cookie field is not unique....there can be a max of 2 tuples with a given cookie number. |
|
Now in the trigger function i check if there are more than one tuple with the cookie number of the tuple being modified or inserted into the table. If there are 2 tuples with the same cookie, i need to check if SentFlag,AckFlag,RTNFlag of both the tables are equal to 1...if so delete both the tuples from the table. I am not able to refer to the tuples in the function....how can i refer to the fields of both the tuples. |
#3
| |||
| |||
|
|
The trigger function below, fired after inserts and updates, might be close to what you need. However, it doesn't enforce the 2-tuple limit -- it only contains the logic to delete records based on the criteria you specified. It worked in the minimal tests I performed, but I'd recommend doing more thorough testing before using it in production. |
#4
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |