Home » Developer & Programmer » Forms » My record is getting saved twice (oracle 10g)
My record is getting saved twice [message #546721] Thu, 08 March 2012 07:29 Go to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
My record is getting saved twice every time I push my button to commit changes to my DB.

I have already records from my table and when I click for that record to update the grade. the same record is getting saved twice.
I have put my queries in on-update trigger to update the grade of my record. I check my query, don't have errors. I don't know what's wrong with this.
Re: My record is getting saved twice [message #546722 is a reply to message #546721] Thu, 08 March 2012 07:37 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Discussed zillion times, search for more info.
Re: My record is getting saved twice [message #546726 is a reply to message #546721] Thu, 08 March 2012 08:02 Go to previous messageGo to next message
TinchoGomez
Messages: 11
Registered: January 2010
Location: Santa Fe - Argentina
Junior Member

I think you are put the insert in the trigger.
Can you copy the trigger here?
Re: My record is getting saved twice [message #546729 is a reply to message #546726] Thu, 08 March 2012 08:10 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
upadte tblstudgrades
set grade = :ADDSTUDGRADES2.grade
where student_id = :ADDSTUDGRADES.stud_id
and subject_code = :ADDSTUDGRADES.subj_code;
Re: My record is getting saved twice [message #546734 is a reply to message #546729] Thu, 08 March 2012 08:23 Go to previous messageGo to next message
TinchoGomez
Messages: 11
Registered: January 2010
Location: Santa Fe - Argentina
Junior Member

I think the problem there isn't here. Please revise the logic.
If you disable the trigger, the record is save one?
Re: My record is getting saved twice [message #546735 is a reply to message #546734] Thu, 08 March 2012 08:30 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
No, I disable the trigger on-update, still it saves the record twice
Re: My record is getting saved twice [message #546736 is a reply to message #546735] Thu, 08 March 2012 08:45 Go to previous messageGo to next message
TinchoGomez
Messages: 11
Registered: January 2010
Location: Santa Fe - Argentina
Junior Member

So, the problem there isn't in the trigger.
Please revise the store procedure or the logic. I'm sure there's twice INSERT sql.
Re: My record is getting saved twice [message #546737 is a reply to message #546736] Thu, 08 March 2012 08:48 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
I think in my daba block. Coz I have 2 tables(dummysection and tblstudgrades)

When the user is done enrolling subjects and schedule I have ON-insert trigger there


INSERT INTO dummysection(student_id, subject_code...)
VALUES(...)

INSERT INTO tblstudgrades(student_id, subject_code)
SELECT student_id, subject_Code
FROM tblstudgrades;

Re: My record is getting saved twice [message #546738 is a reply to message #546737] Thu, 08 March 2012 08:51 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
in my grade block, i have to search for the subjects of the specific student from an LOV, and then i'll add his grade from a textbox and that's where my ON-update trigger fires and then saves twice in my db
Re: My record is getting saved twice [message #546739 is a reply to message #546738] Thu, 08 March 2012 09:00 Go to previous messageGo to next message
TinchoGomez
Messages: 11
Registered: January 2010
Location: Santa Fe - Argentina
Junior Member

Ok, but the record already exists in the table tblstudgrades so why do you insert it newly?
Re: My record is getting saved twice [message #546740 is a reply to message #546738] Thu, 08 March 2012 09:01 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
Let's define terms here.
When you say it's saved twice, I assume you mean it's inserted twice.
Save just means save changes - insert, update or delete.

If you make further changes does a third record get inserted?

Is it doing the insert as well as the update or instead of the update?
Re: My record is getting saved twice [message #546741 is a reply to message #546740] Thu, 08 March 2012 09:02 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
I would say that once again the problem is that you are trying to bypass the default functionality without understanding how the default functionality works.
Re: My record is getting saved twice [message #546742 is a reply to message #546740] Thu, 08 March 2012 09:03 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
Yup! It's inserting and updating at the same time Sad
Re: My record is getting saved twice [message #546743 is a reply to message #546742] Thu, 08 March 2012 09:07 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
What is the block status before and after the record is saved?
What is the record status before and after the record is saved?

Have you put messages in on-insert and on-update to check they are both firing?
Re: My record is getting saved twice [message #546744 is a reply to message #546740] Thu, 08 March 2012 09:07 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
cookiemonster wrote on Thu, 08 March 2012 15:01

If you make further changes does a third record get inserted?

Re: My record is getting saved twice [message #546745 is a reply to message #546744] Thu, 08 March 2012 09:14 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
Quote:
If you make further changes does a third record get inserted?


Yes
Re: My record is getting saved twice [message #546746 is a reply to message #546745] Thu, 08 March 2012 09:16 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
Quote:
What is the block status before and after the record is saved?
What is the record status before and after the record is saved?

Have you put messages in on-insert and on-update to check they are both firing?


transaction complete: 1 record applied and saved.. when I added a new record and Updated the grade.
I haven't put messages on both. How can I know the status of the block?
Re: My record is getting saved twice [message #546748 is a reply to message #546746] Thu, 08 March 2012 09:19 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
if it is new, changed, or query? Am I to put :SYSTEM.BLOCK_STATUS on my message in my data block?
Re: My record is getting saved twice [message #546750 is a reply to message #546748] Thu, 08 March 2012 09:22 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
yes and :system.record_status.
Re: My record is getting saved twice [message #546751 is a reply to message #546750] Thu, 08 March 2012 09:24 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
when I click my save button message says my block status is changed
Re: My record is getting saved twice [message #546752 is a reply to message #546751] Thu, 08 March 2012 09:25 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
where will I put record_status?
Re: My record is getting saved twice [message #546754 is a reply to message #546752] Thu, 08 March 2012 09:26 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
okay I added it after block status.. my messages say block status changed and record status insert
Re: My record is getting saved twice [message #546755 is a reply to message #546752] Thu, 08 March 2012 09:27 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
try key_commit:

message('Status before '||:system.record_status);
commit_form;
message('Status after '||:system.record_status);
Re: My record is getting saved twice [message #546756 is a reply to message #546755] Thu, 08 March 2012 09:33 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
it says record insert and record status after QUERY.
IT's just not updating. What I just want is for the subject to have the grade updated.
Re: My record is getting saved twice [message #546757 is a reply to message #546756] Thu, 08 March 2012 09:53 Go to previous message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you change an existing record in the block and click save is the status insert?
If so I don't know what you've done to break it.

Record_status in a nutshell:
Blank records have status of new.
Once you start typing stuff in the status goes to insert.
Click save and forms inserts the records and sets the status to query.
Make changes to the saved record and the status goes to changed.
Click save and forms updates the records and sets the status to query.

Queried records get a status of query unsurprisingly.


I have no idea what you've done but you've managed to break that some how.
Previous Topic: Problem in connecting to other database user inside a form (merged 2)
Next Topic: oracle developer 11g (forms and reports)
Goto Forum:
  


Current Time: Fri Jul 05 22:53:56 CDT 2024