Home » Developer & Programmer » Forms » ON-insert vs Commit
ON-insert vs Commit [message #493673] Wed, 09 February 2011 05:41 Go to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

Hi create a simple table

create table a
(col1 number(4),
col2 varchar2(10));

which is initially blank....i create a form also for that table..my task is when table found no data , my form values should be inserted on that table...

But i am surprised when i written a code
on button -pressed i write code like this


On-button-pressed trigger
==========================
declare
cnt number(4);

begin

select count(*) into cnt from a;

if cnt = 0 then
insert into a values(:col1,:col2);
end if;
commit_form;
end;


I found 2 record added.....

I cant understand why 2 record added in database...

after that i written same logic on on-insert block
i get exact result...


may i know why 2 record inserted in db...
  • Attachment: DEMO.fmb
    (Size: 48.00KB, Downloaded 990 times)
Re: ON-insert vs Commit [message #493675 is a reply to message #493673] Wed, 09 February 2011 05:52 Go to previous message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Your block is a database block. Your entering values into the items, which changes the block_status to insert.
You run your code which does an insert and a commit. Whenever you do a commit in forms the form checks if there are any changes in any database datablocks that need applying to the DB. There are, it does.

Why are you writing any code here? What's wrong with default forms processing?
Previous Topic: READ_IMAGE_FILE issue
Next Topic: Post-INSERT TRIGGER raised unhandled error
Goto Forum:
  


Current Time: Tue Sep 17 16:22:11 CDT 2024