Translate

Freitag, 27. Oktober 2017

IR with Checkbox select/unselect to A) set values or B) copy specific records

My environment: APEX 5.1.2.00.09 - DB 11.2

My Business case:
Select records in the IR based on the checkbox and copy these - and assign some new values
(here: Date :P107_GUELTIG_AB,  - means: valid from...)

First build the checkbox for the IR based on Jeffs input:


Jeff uses a combination of DA, JQuery and Javascript and the u.m. pl/sql to set a value

Thanks to Jeff!

A) Process type pl/sql code - to set a value within the report/table. :

DECLARE
  MELD_ID WWV_FLOW_GLOBAL.VC_ARR2;
BEGIN
  MELD_ID := APEX_APPLICATION.G_F01;
  FOR IDX IN 1 .. MELD_ID.COUNT
  LOOP
    IF MELD_ID(IDX) IS NOT NULL THEN
      UPDATE MELDUNGEN
      SET ABGERECHNET='Ja'
      WHERE MELD_ID =MELD_ID(IDX);
        END IF;
  END LOOP;
END;

----
Then to my business case:

Select records in the IR based on the checkbox and copy these - and assign some new values (here: Date :P107_GUELTIG_AB,  - means: valid from...)

B) So have modified the above to copy the selected records/values to another (or the same) table:

Process: type pl/sql code

Syntax:

DECLARE
  LST_DEF_ID WWV_FLOW_GLOBAL.VC_ARR2;
BEGIN
  LST_DEF_ID := APEX_APPLICATION.G_F01;
  FOR IDX IN 1 .. LST_DEF_ID.COUNT
  LOOP
    IF LST_DEF_ID(IDX) IS NOT NULL THEN
 --- here insert starts...
insert into LEISTUNGEN_DEFAULT DEF
(
DEF."LST_DEF_ID",
DEF.KD_FK,
DEF.KD_GR_FK, 
DEF."KD_LST_FK", 
DEF."DEF_BETRAG", 
DEF."DEF_ZEIT", 
DEF."DEF_BEZ_KD", 
DEF."DEF_UMFASST_BEMERKUNGEN", 
DEF."DEF_BEMERKUNGEN", 
DEF."DEF_GUELTIG_VON", 
DEF."DEF_AKTIV"  
)
select
LEISTUNGEN_DEFAULT_SEQ.nextval,
--- some ID's to set
:P107_AK_KD_ID,
:P107_KD_GR_ID,
DEF."KD_LST_FK", 
DEF."DEF_BETRAG", 
DEF."DEF_ZEIT", 
DEF."DEF_BEZ_KD", 
DEF."DEF_UMFASST_BEMERKUNGEN", 
DEF."DEF_BEMERKUNGEN", 
---- Date Picker field on the page
:P107_GUELTIG_AB, 
DEF.DEF_AKTIV  
from LEISTUNGEN_DEFAULT DEF
where  DEF."LST_DEF_ID" = LST_DEF_ID(IDX);
    END IF;
  END LOOP;
END;

To make it working you have to add a Date Picker (or other) field on your page