gpt4 book ai didi

javascript - 甲骨文顶点 : Javascript code in PL/SQL Block

转载 作者:数据小太阳 更新时间:2023-10-29 04:18:04 25 4
gpt4 key购买 nike

是否可以在 PL/SQL block 中包含 JavaScript 代码。我想在 oracle Apex 页面进程中提交时执行包含 JavaScript 代码的 pl/sql block 。

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;

我的页面区域中有提交按钮,这个pl/sql block 是页面处理项并在页面提交时执行(Conditional:Submit)。

但是我无法弹出警告框。请指教。

谢谢。

最佳答案

Is it possible to have JavaScript code in the PL/SQL block?

但是,您尝试做的是在提交后传递 javascript 函数是行不通的。只有当您将执行点更改为 AFTER HEADER 时,它才会起作用。

或者,如果您只想验证输入的值而不想使用顶点验证,则可以使用 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;

编辑:如果你想在计数不等于 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;

关于javascript - 甲骨文顶点 : Javascript code in PL/SQL Block,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34263401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com