Reputation: 13
Having a small issue with checkboxes in an Apex report. I've added them to the interactive report fine, and everything works well when one box is selected and submitted for updating. However, I cannot select multiple boxes because I get an error about not having unique primary keys (My own constraint which I cannot break). The following is my current page process(Slightly edited for privacy) to update the database:
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
INSERT INTO table_name(user_photo_id, created_by, created_on, photo_id, user_id)
values(:P58_USER_PHOTO_ID, :F125_USER_ID,sysdate,:P58_PHOTOS, apex_application.g_f01(i));
END LOOP;
The item that the primary key is derived from (:P58_USER_PHOTO_ID) get's the primary key from this code chunk:
declare
function get_pk return varchar2
is
begin
for c1 in (select TABLE_USER_PHOTO_SEQ.nextval next_val
from dual)
loop
return c1.next_val;
end loop;
end;
begin
:P58_USER_PHOTO_ID := get_pk;
end;
Is there anything I can change in either of the two pieces of code so that regardless of how many items are selected, they each get their own unique primary key? Thanks for any help!
Upvotes: 0
Views: 1103
Reputation: 132670
You can ditch the second code chunk and just do this:
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
INSERT INTO table_name(user_photo_id, created_by, created_on, photo_id, user_id)
values(TABLE_USER_PHOTO_SEQ.nextval, :F125_USER_ID,sysdate,:P58_PHOTOS, apex_application.g_f01(i));
END LOOP;
Upvotes: 1