I’m having some issues using checkboxes in combination with an insert/update statement. As it stands, I have a report of available credit cards, with a checkbox next to each row. The user can select as many as they like to approve, then hit a submit button to have their profile updated. This is where I am stuck.
I would like to have a single PSQL process that will update the user profile table based on whether or not said credit card is there. If it doesn’t exist, then we insert all relevant information. If it already is there, all I want to do is update that record by changing ‘Approved_flag’ to ‘Y’. I’ve written this code chunk, which inserts new records and it works fine:
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
INSERT INTO ls_credit_cards(credit_card_id, created_by, created_on, card_id, user_id, approved_flag)
VALUES (apex_application.g_f01(i), :F125_USER_ID,sysdate, :P58_CARDS, :P58_USER, 'Y');
END LOOP;
I understand that ORACLE doesn’t support the usual if/else commands, so I’ve researched this a bit and found that I should probably be using the MERGE command, but everything I’ve seen makes it use two tables. All I’m using is one, with all data being taken from the report/check boxes so I’m kind of at a loss here. Can I still use the MERGE command in this instance, or is there something else that would serve my purposes better?
You can use
MERGE. You just need to select your data from `DUAL’