Getting specific value from checkbox global array variable in oracle apex

扶醉桌前 提交于 2020-01-07 08:23:05

问题


I created an checkbox using apex_item checkbox and the array APEX_APPLICATION.G_F01 contains the values of selected checkbox values .My question how to get the only one specific selected checkbox value from that array . Find my plsql code here and please help me

declare
    var_hire DATE ;
    tenure_dt DATE;
    i number ;
BEGIN
    FOR I IN 1..APEX_APPLICATION.G_F01.count LOOP
        SELECT HIREDATE INTO var_hire from employee where empno=APEX_APPLICATION.G_F01(1);
        SELECT var_hire+ INTERVAL '1' YEAR INTO  tenure_dt FROM DUAL;
             IF SYSDATE < to_Date(tenure_dt,'DD-MON-YY') THEN
                HTP.P('The employee cannot be deleted');    
             END IF ;
    END LOOP ;
END;

New PLSQL CODE

 declare
    l_index number;
    var_hire DATE ;
    tenure_dt DATE;
begin
    for i in 1..APEX_APPLICATION.G_F01.count loop
     if(APEX_APPLICATION.G_F01.exists(i)) then  
         SELECT HIREDATE INTO var_hire from employee where empno=APEX_APPLICATION.G_F01(i);
         SELECT var_hire+ INTERVAL '1' YEAR INTO  tenure_dt FROM DUAL;
         IF SYSDATE < to_Date(tenure_dt,'DD-MON-YY') THEN
              HTP.P('The employee cannot be deleted');    
         END IF ;
     end if ;
    end loop;
 end ;

回答1:


APEX_APPLICATION.G_F01 contains the values of selected checkbox values

That's not what your query suggests:

where empno = APEX_APPLICATION.G_F01(1)

G_F01 is either empno, or a checkbox. Can't be both.

If we suppose that G_F01 really is empno, you have to find which one is your checkbox. How? Inspect element in your browser. If it turns out that checkbox is e.g. G_F05, then you're missing another condition which checks checkbox' value, e.g.

where empno = APEX_APPLICATION.G_F01(1)
  and APEX_APPLICATION.G_F05 = 1             --> this

and then do something with that information.



来源:https://stackoverflow.com/questions/58743467/getting-specific-value-from-checkbox-global-array-variable-in-oracle-apex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!