在pl/sql块中是否可能有javascript代码。
我想在oracle apex页面进程中执行包含javascript代码的pl/sql块。DECLARE
v_count NUMBER;
BEGIN
select count(*) into v_count
from summary
where prd_items = 'Total';
HTP.p ('
HTP.p ( 'alert(''The value of Total for BU is ' ||v_count|| '.\n'
|| 'You have to enter correct values to proceed further \n'');');
HTP.p ('');
END;
我的页面区域中有Submit按钮,这个pl/sql块是页面处理项,在页面提交时执行(Conditional:Submit)。
但我无法弹出警报框。请告知。
谢谢您。
最佳答案:
在pl/sql块中可以有javascript代码吗?
对
但是,在提交之后传递javascript函数是行不通的,只有将执行点改为after header才行。
或者,如果您只想验证输入的值而不想使用Apex验证,则可以使用Apex_错误包。请尝试此操作。DECLARE
v_count NUMBER;
BEGIN
select prd_items into v_count
from summary
where prd_items = 'Total';
-- I dont really know what you want to
--accomplish with this query but Im pretty sure
--It will not return a number
-- if you want to count the number of prd_items it should be like this
--select COUNT(*)
--into v_count
--from summary
--where prd_items = 'Total';
APEX_ERROR.ADD_ERROR(
p_message => 'The value of Total for BU is '||v_count||'.
'||
'You have to enter correct values to proceed further',
p_display_location => apex_error.c_inline_in_notification
);
END;
编辑:如果要在计数不等于100时显示错误,请执行以下操作:
DECLARE
v_count NUMBER;
BEGIN
Select COUNT(*)
into v_count
from summary
where prd_items = 'Total';
IF v_count != 100 THEN
APEX_ERROR.ADD_ERROR(
p_message => 'The value of Total for BU is '||v_count||'.
'||
'You have to enter correct values to proceed further',
p_display_location => apex_error.c_inline_in_notification
);
END IF;
END;