how to update/insert multiple records at a time [message #312298] |
Tue, 08 April 2008 08:12  |
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   |
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!
|
|
|
|