on-insert trigger [message #606181] |
Mon, 20 January 2014 23:43 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](http://www.gravatar.com/avatar/a59247482a11edb9544247f102223e8d?s=64&d=mm&r=g) |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi all,
I want insert new records into the emp table ,i have written on-insert/pre-insert trigger at the emp block level,It is working fine, i am not getting messages at the left bottom "1 record inserted and saved transaction" like, but the values are inserted into the emp table..
IF :System.RECORD_STATUS ='NEW' THEN
insert_record;
Commit_Form();
END IF;
![/forum/fa/11637/0/](/forum/fa/11637/0/)
Thank You
-
Attachment: image1.png
(Size: 19.40KB, Downloaded 3985 times)
[Updated on: Tue, 21 January 2014 00:21] Report message to a moderator
|
|
|
|
Re: on-insert trigger [message #606196 is a reply to message #606192] |
Tue, 21 January 2014 01:29 ![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) |
![](http://www.gravatar.com/avatar/a59247482a11edb9544247f102223e8d?s=64&d=mm&r=g) |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Thank You for reply Littlefoot,
I have 2 canvas(emp,emp_control), i add deptno&find in the emp_control for searching records based on the deptno ,it navigates to the emp block and displayed records. So, i have taken where clause.Firstly added on-insert trigger at the EMP(Database Block) for directly insert the records in the emp table, but it is not worked.
Now i am able to insert , update & delete the records.
My another Question is:
I select the deptno=30 & click the find button , it navigates to the database block & displayed 30th records,after the last record, i am getting frm-40102 record must be entered or deleted first, how can i remove such error's suggest me please
|
|
|
|
Re: on-insert trigger [message #606201 is a reply to message #606181] |
Tue, 21 January 2014 02:30 ![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) |
![](http://www.gravatar.com/avatar/a59247482a11edb9544247f102223e8d?s=64&d=mm&r=g) |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
I got the solution for frm-40102 record must be entered or deleted first & FRM-40352: Last record of query retrieved.
At the form level
ON-ERROR
--------
IF ERROR_CODE=40102 THEN
null;
ELSE
MESSAGE(ERROR_TEXT);
MESSAGE(ERROR_TEXT);
RAISE FORM_TRIGGER_FAILURE;
END IF;
--if :system.record_status!='NEW' then
--create_record;
--end if;
-if error_type = 'FRM' and error_code = 40352 then
--null;
--end if;
ON-MESSAGE
----------
IF :System.last_record = 'FALSE' THEN -->FRM-40352: Last record of query retrieved.
Next_Record;
END IF;
[Updated on: Tue, 21 January 2014 02:31] Report message to a moderator
|
|
|
Re: on-insert trigger [message #606206 is a reply to message #606201] |
Tue, 21 January 2014 04:03 ![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) |
cookiemonster
Messages: 13937 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
When getting an error you don't expect, it is never the correct solution to write some code to hide the error.
It is always the correct solution to find what is causing the error in the first place and fix it.
You get that error when you try to navigate away from a partially entered record in a database block.
So work out what is partially entered (checking :system.record_status may help) and ensure the user is prompted to save their changes first.
As for inserting: The simplest way to get forms to insert data is to write no code. You should never, under any circumstances need an on-insert trigger. You should rarely need a pre-insert, and it should never contain the code you say you've used.
So why don't you tell us what problem you trying to solve by creating these triggers in the first place?
|
|
|
|
Re: on-insert trigger [message #606210 is a reply to message #606207] |
Tue, 21 January 2014 04:23 ![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) |
cookiemonster
Messages: 13937 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You do realise that forms automatically inserts directly into tables for database datablocks without you having to write any code?
|
|
|
Re: on-insert trigger [message #606212 is a reply to message #606210] |
Tue, 21 January 2014 04:25 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](http://www.gravatar.com/avatar/a59247482a11edb9544247f102223e8d?s=64&d=mm&r=g) |
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Quote:You do realise that forms automatically inserts directly into tables for database datablocks without you having to write any code?
Yes I did cookiemonster, with just sample form contains 2 blocks(database,control) & 2 canvas.
|
|
|