Ziad Adnan
Ziad Adnan

Reputation: 822

How can I customize DML process for interactive grid and submit all rows on save?

I have an interactive grid that displays the values from the following SQL query:

 select  ID , 
         TESTID,
         MACHINE_ID,
         PROGRAM_ID,
         SAMPLE_ID,
         MEAN,
         SD,
         LOW_LIMIT,
         HIGH_LIMIT,
         TESTUNIT
         FROM HAJJ_SAMPLE_DETAILS 
         where sample_id = :P88_SAMPLE
         and program_id = :P88_PROGRAM
         and machine_id = :P88_MACHINE

I used dynamic action to filter the data .

Then I need to insert the data into the database on different table , I updated the DML process like this :

begin
    case :APEX$ROW_STATUS
    when 'C' then
       INSERT INTO HAJJ_QC_RESULTS (HOSPITAL_NO,TESTID, APPROVED_DATE,
        MACHINE_ID, PROGRAM_ID, SAMPLE_ID, MEAN,SD, LOW_LIMIT, HIGH_LIMIT,
       UNITID) 
VALUES (:P0_HOSPITAL_NO, :TESTID , :P88_SAMPLEDATE, :MACHINE_ID , :PROGRAM_ID ,:SAMPLE_ID ,
         :MEAN , :SD , :LOW_LIMIT , :HIGH_LIMIT , :TESTUNIT )
        returning ID_NO into :ID_NO;
  
    end case;
end;

this is the image of IG :

enter image description here

when I click save button its not saving and not show message or error ,

How can I insert the data into the database from IG into different table ?

Upvotes: 1

Views: 787

Answers (1)

Koen Lostrie
Koen Lostrie

Reputation: 18695

An IG only submits changed (and new) rows to the server. This is mentioned here ("When a model is saved, either by the Interactive Grid or when the whole page is saved, just the changed records are gathered up and converted to JSON to send to the server").

Here is an example on the emp/dept sample data set that posts all records to the server, even if the user does not make any changes to any rows. The mechanism is to add a dummy column to the grid and set a value for it in all rows on page load.

  • Create an interactive grid on a select from EMP, including an additional column "DUMMY_CHANGE"
select EMPNO,
       ENAME,
       JOB,
       MGR,
       HIREDATE,
       SAL,
       COMM,
       DEPTNO,
       NULL AS DUMMY_CHANGE
  from EMP
  • Set column "DUMMY_CHANGE" as hidden, source type "None" and value protected = No

  • Give the interactive grid a static id of emp

  • In Page Attributes > Execute when Page Loads put the following code:

let model = apex.region("emp").call("getCurrentView").model;
model.forEach( function( record, index, id ) {
    model.setValue( record, "DUMMY_CHANGE", "X" );
} );
  • Run the page and observe all rows are marked as "edited" (blue triangle in first cell) . If the page is run in debug you can see each row is being processed on save. enter image description here

Upvotes: 2

Related Questions