Home » Developer & Programmer » Forms » Duplicate records to database when entering data from form (Oracle Forms Builder)
Duplicate records to database when entering data from form [message #331713] Fri, 04 July 2008 17:56 Go to next message
CatalinaD
Messages: 2
Registered: July 2008
Junior Member
Hi
Can anyone help me with this?
I created an Oracle Form with a 'when-button-pushed' trigger:

declare
cod_client number(30);
begin
select COD_CL_SEQ.nextval into cod_client from dual;
insert into clienti values
(cod_client,:clienti.nume_client,:clienti.adresa_client,:clienti.cui_cnp,:clienti.banca,:clienti.cod_iban);
end;
COMMIT;

It inserts the data into the table but it duplicates it.

90000081 AASD ASDASD 1234 ASAD ASDASD
(null) AASD ASDASD 1234 ASAD ASDASD

90000086 SDFDF FSDG 24132 SDFASD CSADAF
(null) SDFDF FSDG 24132 SDFASD CSADAF

Does anyoane know why and how do I fix the problem?

Thank you
Re: Duplicate records to database when entering data from form [message #331735 is a reply to message #331713] Sat, 05 July 2008 02:30 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Why don't you let Forms handle the database-actions?
Why do you think you have to explicitly code the insert? Or is your block not based on a database-table?
Re: Duplicate records to database when entering data from form [message #331739 is a reply to message #331735] Sat, 05 July 2008 02:53 Go to previous messageGo to next message
CatalinaD
Messages: 2
Registered: July 2008
Junior Member
Because the forms I create are ment to calculate certain values.
For example to insert into a table named INVOICES values, the user selects only the client and the form should handle the insert into INVOICES by adding 2 fields from table DEBT....
Re: Duplicate records to database when entering data from form [message #331744 is a reply to message #331739] Sat, 05 July 2008 03:16 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Ok, that makes sense.
To see what happens, add a message() line to your trigger (followed by another message() to make the first one pop-up). That way you can see if the trigger fires twice.
If so, investigate further; add some more debugging, dig into the logic of your form.
Re: Duplicate records to database when entering data from form [message #331821 is a reply to message #331744] Sat, 05 July 2008 14:35 Go to previous messageGo to next message
Littlefoot
Messages: 20899
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This is how I see it:

  • the first insert is done by default (user has entered values into data block items and these items are stored into a table)
  • the second insert is done by your INSERT INTO statement. All columns are duplicated, except the one (ones) you calculate and insert instead of default block values)

What to do? Don't use INSERT statement, but write the PRE-INSERT trigger which will calculate desired values, set data block items to these values and, finally, let Forms do the rest (i.e. insert a record into the database).
Re: Duplicate records to database when entering data from form [message #331824 is a reply to message #331821] Sat, 05 July 2008 14:47 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
That was exactly my point in my first reply. The reply by CatalinaD, however, suggested otherwise..
Re: Duplicate records to database when entering data from form [message #331825 is a reply to message #331824] Sat, 05 July 2008 14:55 Go to previous message
Littlefoot
Messages: 20899
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Yes, I understood what you were saying. But I'm afraid Catalina didn't, so - I tried to use another words to convince her that that's not the way to do the job.
Previous Topic: Disable the form
Next Topic: Enter Dates according to Financial Year
Goto Forum:
  


Current Time: Wed Dec 07 12:54:13 CST 2016

Total time taken to generate the page: 0.06597 seconds