Home » Developer & Programmer » Forms » Pre-Insert trigger doesn't fire
Pre-Insert trigger doesn't fire [message #426310] Wed, 14 October 2009 18:27 Go to next message
secchan20
Messages: 31
Registered: April 2005
Member
Hi,
I added pre-insert trigger in form level and block level to pop up my message (only for testing purpose at this point). However, it doesn't always fire even when a record is inserted by when-button-pressed or key-commit trigger. Why? Is it supposed to fire on particular "insert" only?
Any advice is appreciated.
Re: Pre-Insert trigger doesn't fire [message #426391 is a reply to message #426310] Thu, 15 October 2009 04:04 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Try removing the one at form level - it makes no sense to have a pre-insert trigger at that level.
Pre-insert on a datablock always fires when a record is inserted from that datablock.
It doesn't fire if you code an INSERT statement.
Re: Pre-Insert trigger doesn't fire [message #426474 is a reply to message #426391] Thu, 15 October 2009 11:12 Go to previous messageGo to next message
secchan20
Messages: 31
Registered: April 2005
Member
I will try your advice, and I didn't know if won't fire with INSERT statement... Thank you.
Re: Pre-Insert trigger doesn't fire [message #426483 is a reply to message #426310] Thu, 15 October 2009 16:21 Go to previous messageGo to next message
fredg
Messages: 8
Registered: October 2009
Location: NZ
Junior Member
hi dude, i was asking a similar query in this forum a couple days ago then figured out by Littlefoot's help.

Try removing trigger in form level and then moving your script from PRE-INSERT to WHEN-CREATE-RECORD in Data block level.

Re: Pre-Insert trigger doesn't fire [message #426484 is a reply to message #426483] Thu, 15 October 2009 16:33 Go to previous messageGo to next message
secchan20
Messages: 31
Registered: April 2005
Member
Thank you fredg. I will try to remove pre-insert from form level. When-create-record may not work as I want to prevent user from inserting a new record with null value in one field and thought that pre-insert seems to be right place. I want to avoid altering table to make the field "not null" as some existing old records have null values.
Re: Pre-Insert trigger doesn't fire [message #426488 is a reply to message #426484] Thu, 15 October 2009 18:03 Go to previous messageGo to next message
fredg
Messages: 8
Registered: October 2009
Location: NZ
Junior Member
hi dude, the PRE-INSERT will be invoked once you click "SAVE" on toolbar,and the WHEN-CREATE-RECORD can be invoked when you click "Insert record" on toolbar.

Re: Pre-Insert trigger doesn't fire [message #426519 is a reply to message #426310] Fri, 16 October 2009 04:00 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Just to clarify.
WHEN-CREATE-RECORD fires when the datablock creates a new blank record for you to insert data into.
PRE-INSERT fires before forms inserts that record into the database. Note that if you ever use the post command this will fire it, it doesn't have to be commit.

What you need here is PRE-INSERT.

That said the ideal solution would be to update the existing null values with some suitable value (assuming there is one) and then add the NOT NULL constraint.

Failing that you will need PRE_INSERT.
Re: Pre-Insert trigger doesn't fire [message #428320 is a reply to message #426519] Tue, 27 October 2009 19:17 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Use the 'when-validate-record' trigger.

David
Previous Topic: oracle form & list item (merged)
Next Topic: Moving between records in a multi-record block (merged 10)
Goto Forum:
  


Current Time: Fri Sep 20 14:32:06 CDT 2024