Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 10 of 11 total |
Trigger question.. |
Thu, Oct 7 2021 8:44 PM | Permanent Link |
Ian Branch | Hi Team,
Does this trigger only work when a record is changed (UPDATED) or when a new record is inserted as well? {sql} CREATE TRIGGER "SetDateToFinance" BEFORE UPDATE OF "JobStatus" ON "JobTickets" BEGIN IF OLDROW.JobStatus <> 'FI' and NEWROW.JobStatus = 'FI' THEN SET NEWROW.DateToFinance = CURRENT_TIMESTAMP; END IF; END {sql} If it doesn't work for INSERTs then I need to add another Trigger for that condition. Regards & TIA, Ian |
Thu, Oct 7 2021 9:04 PM | Permanent Link |
Ian Branch | I need to trigger to operate for INSERT & UPDATE.
|
Fri, Oct 8 2021 2:55 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Ian
Correct - give that man a Kewpie doll If you don't know what a Kewpie doll is - https://en.wikipedia.org/wiki/Kewpie Roy Lambert |
Fri, Oct 8 2021 1:41 PM | Permanent Link |
Fernando Dias Team Elevate | Hello Ian,
To create a trigger that works both for insert and update do this: CREATE TRIGGER "<YourTriggerName>" BEFORE ALL ON "<YourTableName>" WHEN OPERATION = 'Insert' OR OPERATION = 'Update' BEGIN ... END -- Fernando Dias [Team Elevate] |
Fri, Oct 8 2021 3:09 PM | Permanent Link |
Ian Branch | Roy, Yes I know what a Kewpie doll is. I am that old.
Not that I ever had one of course. |
Fri, Oct 8 2021 3:11 PM | Permanent Link |
Ian Branch | Fernando,
Thank you, I will have a play. I still need to separate the actions between the BEGIN - END as obviously in an INSERT there is no OLDROW Regards, Ian |
Fri, Oct 8 2021 8:41 PM | Permanent Link |
Fernando Dias Team Elevate | Ian,
<<I still need to separate the actions between the BEGIN - END as obviously in an INSERT there is no OLDROW>> Right, but thats easy: BEGIN IF OPERATION = 'Insert' THEN ... ELSE ... END IF; END -- Fernando Dias [Team Elevate] |
Sat, Oct 9 2021 3:03 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Fernando
I tend not to use that one much and had forgotten it Ahhh the joys of aging. Roy Lambert |
Sat, Oct 9 2021 3:58 AM | Permanent Link |
Ian Branch | Thanks Fernando,
Still so much to learn... Regards, Ian |
Sat, Oct 9 2021 7:30 AM | Permanent Link |
Fernando Dias Team Elevate | Roy,
<< Ahhh the joys of aging.>> The alternative is way worst -- Fernando Dias [Team Elevate] |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Wednesday, April 24, 2024 at 11:07 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |