FrontBase triggers howto (was: Never save objects which don't pass a test (was: searching for a weird deletion))
FrontBase triggers howto (was: Never save objects which don't pass a test (was: searching for a weird deletion))
- Subject: FrontBase triggers howto (was: Never save objects which don't pass a test (was: searching for a weird deletion))
- From: OC <email@hidden>
- Date: Sat, 21 Feb 2015 16:52:21 +0100
Hello there,
after having played for a time with constraints, I have decided to use a trigger instead -- main reason is that I really want the validation performed on INSERT only; a constraint might get evaluated in other occassions, too.
Nevertheless, I can't find a decent way of doing that in FrontBase. Is here anybody who knows its dialect well enough?
Ideally, the trigger would look more or less like this:
===
create trigger TEST_PO_TRIGGER before insert on T_PRICE_OFFER
referencing new po for each row when (... my complex validation condition ...)
raise exception 'Price offer not valid'
===
presumed RAISE EXCEPTION worked in FrontBase, which it does not, nor I was able to find any other statement/function to rollback the transaction and report an error.
Presumed there's no such function at all, the first fallback would be
===
create trigger TEST_PO_TRIGGER before insert on T_PRICE_OFFER
referencing new po for each row when (... my complex validation condition ...)
set po.C_UID = null
===
which would exploit the fact C_UID (which happens to be the PK) can't be null. Alas, again, whatever I tried, I haven't been able to find any SET syntax which would work :(
Eventually, the only trigger I found working was
===
create trigger TEST_PO_TRIGGER after insert on T_PRICE_OFFER
referencing new po for each row when (... my complex validation condition ...)
update T_PRICE_OFFER set C_UID = null where C_UID=po.C_UID
===
but darn, that seems to be a _terribly_ convoluted work-around for the desired behaviour!
As always, I'll be grateful for any advice,
OC
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden