message on trigger [message #241259] |
Tue, 29 May 2007 00:40 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
|
Hi all,
I created trigger for BEFORE INSERT OR UPDATE. When testing, I want to pop a message just like in forms(message('msg')). How to do this in trigger? I tried these two but no message poped up.
RAISE_APPLICATION_ERROR (-20100, 'Operation not allowed');
DBMS_OUTPUT.PUT_LINE('here');
|
|
|
Re: message on trigger [message #241261 is a reply to message #241259] |
Tue, 29 May 2007 00:42 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
Where do you want to 'pop' your message to?
A database trigger runs on the database server.
A guess:
Remove your exception handler (when others then dbms_output.put_line....).
|
|
|
|
Re: message on trigger [message #241267 is a reply to message #241259] |
Tue, 29 May 2007 01:08 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
|
I want it to pop on forms after I insert/update records, just like alert or double message on forms. Now, if it's not possible, how can I catch error return by that trigger on forms so that I can code message on forms?
|
|
|
|
|
|
|
|
Re: message on trigger [message #241876 is a reply to message #241259] |
Wed, 30 May 2007 15:32 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
hemavb
Messages: 103 Registered: May 2007 Location: Dubai , UAE
|
Senior Member |
|
|
U have 2 options:
Option 1: Block level trigger.
if the insert/update is happening thru forms and you are using a database block, the easiest thing is to tranfer your triggers from the database to the block. Use Pre-insert for Before Insert trigger and Post-Insert for After Insert trigger. Same will be for Update and Delete triggers
Pre triggers fire before Commit/Post statements hit the database.
Post triggers fire after the data is commited.
Drawback:
you will have to use this particular form for entering data to the database at all times. Any insert or update done from the other forms/directly from the SQL or database will not fire any triggers.
Option 2: Pre-commit Checks.
AT the form -level triggers in forms, put all the exception checks that may cause the insert/update/delete triggers to fail, in the PRE-COMMIT trigger. DONOT use GO_ITEM or GO_BLOCK procedures here. You donot have to say COMMIT as this trigger runs before passing on a COMMIT or POST command to the Database.
Drawback:
For this you have to be clear of what all errors/exceptions may occur.
Lemme know if you need any clarifications.
|
|
|