Home » Developer & Programmer » Forms » how to update/insert multiple records at a time (forms6i,winxp)
icon7.gif  how to update/insert multiple records at a time [message #312298] Tue, 08 April 2008 08:12 Go to next message
rocky.
Messages: 2
Registered: April 2008
Junior Member
hey can u please help me out to how to update multiple records at a time
like i kept number of records displayed is 5

let me explain u what my problem is i doing project on HRMIS so i created a form in that am having tabs while it runs it asks about the empcode and by clicking it all the details of the employee will be displayed and i kept edit options for every tab and in that tab i kept family tab and in that i kept multiple records and in that i kept save button i kept when_button_pressed in that i gave


begin
execute_query;
set_edit_relation;
end;



and in program units i gave



PROCEDURE set_edit_relation IS
BEGIN
go_block('family');
first_record;
loop
update emp_relations set rel_name=:family.name,rel_relation=:family.relation,rel_dob=:family.dob,
rel_occupation=:family.occupation,rel_dependent=:family.dependent
where empcode=:empcode.empcode;
exit when :system.last_record = 'TRUE';
next_record;
end loop;
commit;
message('Record Saved');
message('Record Saved');
commit;

END;

and it compiled well but by clicking save button it is not storing in database
and please send me detail code

[Updated on: Tue, 08 April 2008 08:24]

Report message to a moderator

Re: how to update/insert multiple records at a time [message #312304 is a reply to message #312298] Tue, 08 April 2008 08:45 Go to previous messageGo to next message
solisdeveloper
Messages: 48
Registered: March 2008
Location: Mexico
Member
Hi Rocky:

Most members will tell you to please put your code between code tags, and make sure it's properly formated so that it's easy to read and understand, so do it next time.

Anyway, if what you want is to navigate the block from the first to the last record in it, and update each record then your code should look like this:

PROCEDURE set_edit_relation IS
BEGIN
  go_block('family');
  first_record;
  WHILE :SYSTEM.last_record <> 'TRUE' THEN
    UPDATE emp_relations set...
    Instruction 2...
    Instruction 3...
    next_record;
  END LOOP;
  last_record;  --Otherwise you will never save the last record
  UPDATE emp_relations ...
  Instruction 2...
  COMMIT;
  message('Record Saved');
END;


Hope this helps.
Regards!
Re: how to update/insert multiple records at a time [message #312437 is a reply to message #312304] Tue, 08 April 2008 20:11 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Use 'standard.commit' NOT 'commit' in procedures that reside in a form. Search this forum for 'standard.commit' for a fuller explanation.

David
Previous Topic: error on executing form in when-validate-item trigger
Next Topic: Create Hyperlink on Form (10g)
Goto Forum:
  


Current Time: Wed Dec 07 02:41:08 CST 2016

Total time taken to generate the page: 0.43654 seconds