Ape*_*Dev 8 javascript oracle plsql oracle-apex
是否可以在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 ('<script type="text/javascript">');
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 ('</script>');
END;
Run Code Online (Sandbox Code Playgroud)
Submit我的页面区域中有按钮,这个pl/sql块是页面处理项,并在页面submit(Conditional:Submit)上执行.
但是我无法弹出警报框.请指教.
谢谢.
是否可以在 PL/SQL 块中包含 JavaScript 代码?
但是,您尝试执行的在 SUBMIT 之后传递 javascript 函数的操作不会起作用。只有将执行点更改为 AFTER HEADER 时,它才会起作用。
或者,如果您只想验证输入的值并且不想使用 apex 验证,则可以使用 APEX_ERROR 包。试试这个。
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||'.<br>'||
'You have to enter correct values to proceed further',
p_display_location => apex_error.c_inline_in_notification
);
END;
Run Code Online (Sandbox Code Playgroud)
编辑:如果您想在计数不等于 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||'.<br>'||
'You have to enter correct values to proceed further',
p_display_location => apex_error.c_inline_in_notification
);
END IF;
END;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18344 次 |
| 最近记录: |