【问题标题】:Calling a function from Oracle forms从 Oracle 表单调用函数
【发布时间】:2018-02-03 11:02:59
【问题描述】:

我在 Windows 机器上使用 Oracle Forms 6i 和 Oracle db 10g,在一个表单中,当我点击一个按钮时,触发器 WHEN-BUTTON-PRESSED 被启动,调用数据库中的一个包的函数,这里是触发器和函数的 PL/SQL 代码:

功能:

Function test_function (code Varchar2) RETURN Varchar2 IS
BEGIN
    if code IN ('Y') then
        return('Yes');
    else 
        return('no');
    endif;
END;

触发器:

DECLARE
    message_test varchar2(20);
BEGIN
    message_test := pkg_test.test_function('Y');
    message('the message is: ' || message_test);pause;
END;

我的问题是它没有显示任何内容,但是当我在 sql*plus 或 SqlDeveloper 中编写 pkg_test.test_function('Y') 时,结果显示 'Yes'

或者当我将message_test := pkg_test.test_function('Y'); 更改为select pkg_test.test_function('Y') into message_test from test; 时,它也可以工作。

这可能是什么原因?

PS:这只是一个测试代码,实际代码比这更复杂。

【问题讨论】:

  • 你的输出是空白的吗?或者它是否显示“消息是:”并且没有消息?因为如果它是第一个,那么你的 message() 函数没有做任何事情,但如果它是第二个,问题在于调用 pkg_test.test_function()。
  • @kfinity 它是空白的,没有“消息是:”,问题在于调用 pkg_test.test_function()。
  • 嗯,也许您遇到了错误?您可以将触发器的结尾更改为:EXCEPTION when others then message(dbms_utility.format_error_backtrace); END; 以查看它是什么。
  • @kfinity "message(dbms_utility.format_error_backtrace)" 在 oracle 表单中不起作用!
  • @zenami 那么,在 pkg_test.test_function 中尝试以下操作(不在触发器中):exception when others then begin rollback; raise_application_error(-20710,'My problem is '||dbms_utility.format_error_stack||dbms_utility.format_error_backtrace||'['||dbms_utility.port_string||']'); end; 顺便说一句,为什么 pause; 这个词会站在那里?

标签: oracle function package oracle-sqldeveloper oracleforms


【解决方案1】:

如果只是测试,可以试试show alert()函数吗?

DECLARE
    message_test varchar2(20);
    alert_resp number;
BEGIN
    message_test := pkg_test.test_function('Y');
    set_alert_property('ALERT_OK','the message is: ' || message_test);
    alert_resp := show_alert('ALERT_OK');
END;

确保在表单警报中创建警报 ALERT_OK。

【讨论】:

  • 'Show_alert' 只有一个参数是警报的名称/ID,所以这一行不起作用“alert_resp := show_alert('ALERT_OK','消息是:' || message_test);"
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-10-20
  • 2011-08-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多