Home » Developer & Programmer » Forms » Double insertion! (oracle forms 6i,XP)
Double insertion! [message #545091] Mon, 27 February 2012 04:10 Go to next message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

Hi all..
when i tried to insert the details from oracle froms..the data inserts twice to the DB..

my table structure:

create table app_sri
(a_id integer primary key,
p_first_name varchar2(30),
p_last_name varchar2(20),
p_age number(3)
);


here a_id can be genarated through simple sequence(pid_seq)...

trigger on app_sri
create or replace trigger pid_trg
  before insert on app_sri
  for each row
begin
select pid_seq.nextval into :new.a_id from dual;
end;




form insertion code..

Begin

insert into app_sri(null,'robo','Big',100);
commit

End;




the data inserted...but twice

what is the reason behind the double insertion?
Re: Double insertion! [message #545092 is a reply to message #545091] Mon, 27 February 2012 04:13 Go to previous messageGo to next message
Littlefoot
Messages: 18847
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Remove the last code (the whole trigger or simply comment it) you posted (INSERT INTO APP_SRI ...) and run the form again. What happens?
Re: Double insertion! [message #545096 is a reply to message #545092] Mon, 27 February 2012 04:22 Go to previous messageGo to next message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

I heve commented the (INSERT INTO APP_SRI...) code...
nothing happend..

(WHEN-BUTTON-PRESSED trigger had the (INSERT INTO APP_SRI...)code..
Re: Double insertion! [message #545098 is a reply to message #545096] Mon, 27 February 2012 04:27 Go to previous messageGo to next message
Littlefoot
Messages: 18847
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
My assumption was that COMMIT saved both values from the data block and through the INSERT statement. It appears that I was wrong.
Re: Double insertion! [message #545099 is a reply to message #545096] Mon, 27 February 2012 04:29 Go to previous messageGo to next message
cookiemonster
Messages: 10593
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you have a datablock based on a table, and you enter values into the datablock and click the save button, forms will automatically insert the data into the DB. No insert statement needed.
Likewise if you query a record, modify it and click save, forms will automatically update the data in the DB. No update statement needed.
You need to learn to use the default functionality.
Re: Double insertion! [message #545102 is a reply to message #545099] Mon, 27 February 2012 04:36 Go to previous messageGo to next message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

thanks...i have removed the insert statement...
It works fine...
Re: Double insertion! [message #545103 is a reply to message #545102] Mon, 27 February 2012 04:49 Go to previous messageGo to next message
Littlefoot
Messages: 18847
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, "removing" it is the same as "commenting" it. Code that is commented doesn't execute.

So, if you commented it previously (as I suggested) and it didn't work properly, how come it works OK now (when you removed it)? Which of your messages is not true (or - is a lie? Don't lie to me!).
Re: Double insertion! [message #545111 is a reply to message #545103] Mon, 27 February 2012 05:36 Go to previous messageGo to next message
cookiemonster
Messages: 10593
Registered: September 2008
Location: Rainy Manchester
Senior Member
You mean your avatar pic isn't an instruction?
Re: Double insertion! [message #545113 is a reply to message #545111] Mon, 27 February 2012 05:46 Go to previous message
Littlefoot
Messages: 18847
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
./fa/9000/0/
Previous Topic: Passing values (merged 2)
Next Topic: How to make a node?
Goto Forum:
  


Current Time: Thu Apr 24 23:48:44 CDT 2014

Total time taken to generate the page: 0.05985 seconds