dimanche 19 mars 2023

How to create a button to copy rows from one table to another - APEX

I have an interactive grid page and the checkbox was created using APEX$ROW_SELECTOR. I would like to copy the rows that was selected by the user to another table when the user clicks the button.

What I tried so far?

  • I created a button and a process for the button click event. Set the process point to "Button" and selected the button I created for copying rows.

I used the following code in the process.

DECLARE
   l_selected_rows apex_application_global.vc_arr2;
BEGIN
   -- Get the selected rows from the source table
   l_selected_rows := apex_application.g_f01;
   
   -- Insert the selected rows into the destination table
   INSERT INTO destination_table
      (col1, col2, col3)
   SELECT
      col1, col2, col3
   FROM
      source_table
   WHERE
      row_id IN (SELECT column_value FROM TABLE(l_selected_rows));
   
   -- Display a success message
   apex_application.g_message := 'Selected rows copied to destination table.';
END;

But, when I run the application and click the button the selected rows data doesn't copy to the other table. What could be the problem?




Aucun commentaire:

Enregistrer un commentaire