This content has been marked as final. Show 5 replies
Pls use the Built in Function IN When-Create-Record or in When-New-Record-Instance
DUPLICATE_RECORD;But for the group no am not sure how u would keep two records with the same sequence or the like....
You can use something like this:
Hope this helps (I write from memory so it can be some syntax bugs - hope you can fix it :))
declare groupNo integer; -- change data type appropriate no number := :system.cursor_record; begin groupNo := :block_name.group_no; --to store current group_no; first_record; while true loop --iterate through all records in the block if :block_name.group_no = groupNo then --only affected records; create_record; Duplicate_Record; :block_record.group_no := groupNo +1; --or any other value end if; exit when :system.last_record = 'TRUE'; next_record; end loop; go_record(no); end;
I have developed a example form and tested, and its works as your requirement.
i have created a table with three three fields and the same data as u mentioned in post.
I the button just paste the code and hope it will work.
cursor c_test is select name,city,group_no from TEST_EXAMPLE;
for C_test_rec in C_test
:XXNEXTBLK.NAME := C_test_rec.name;
:XXNEXTBLK.CITY := C_test_rec.city;
when too_many_rows then
when others then
cursor c_test1 is select name,city,group_no from TEST_EXAMPLE;
if :XXNEXTBLK.GROUP_NO =1 then
for C_test1_rec in C_test1
:XXNEXTBLK.NAME := C_test1_rec.name;
:XXNEXTBLK.CITY := C_test1_rec.city;
Check it, if any issue just send a mail to firstname.lastname@example.org, ill forward the fmd to you.
Thanks & Regards
Many many thanks to all you guys for suggesting solutions.
My work day has just started and will let you know how they go.
I am not sure but since you have used a cursor in your solution, I am assuming that the select query is against the base table.
Perhaps I was not clear enough describing my problem, but the requirement is to do the copy at the block level only, since none of the records have been saved to the table yet. It is only after all the records have been created for multiple groups, that I would like to save the records to the table.