问题
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