【问题标题】:Insert statement doesn't recognise the variable values插入语句无法识别变量值
【发布时间】:2019-03-03 12:18:55
【问题描述】:

包装上的代码可以正常工作。从 oracle 表单中,我正在尝试将新条目插入到表中。

错误信息

ORA-01400: 无法将 NULL 插入 ("BUS"."BP_AUTH_CODE"."CODE")

代码

Declare
    v_bn varchar2(9);
    v_bn_exists number;
    v_has_auth_code number;
    v_auth_code varchar2(9);
Begin
    v_bn := :TAC.bn;

    v_bn_exists := CG$BP_AUTH_CODE.bn_exists(v_bn);

    if v_bn_exists = 1 then
        .....

        if v_has_auth_code = 1 then
            ...
        else
            v_auth_code := CG$BP_AUTH_CODE.make_auth_code;
            --Error happening over here
            insert into bp_auth_code (bn, code) values(v_bn, v_auth_code);
            commit;
            message(v_auth_code); -- I can see the value
        end if; 

    else
        ....
    end if;

End;

【问题讨论】:

  • 您是否有一个触发器,可以将相同的值复制到具有相同名称、不同模式(总线)的表中。我的意思是,您确定您的表单在运行时连接到 bus 架构吗?

标签: oracle oracle10g oracleforms


【解决方案1】:

恐怕你搞错了:

v_auth_code := CG$BP_AUTH_CODE.make_auth_code;
--Error happening over here
insert into bp_auth_code (bn, code) values(v_bn, v_auth_code);
commit;
message(v_auth_code); -- I can see the value

说“你可以看到价值”——不,你不能。

如果 INSERT 失败,Oracle 会引发 ORA-01400 错误,因此执行会停止。 INSERT 后面没有执行任何操作,包括 MESSAGE 调用。你不可能知道它的价值,但是 - 如果我是你,我会相信甲骨文。如果它说CODE 为空,那么它就是。

根据您使用的表单版本,您可以(始终)将代码(出于调试目的)重写为

v_auth_code := CG$BP_AUTH_CODE.make_auth_code;
message(v_auth_code);             -- now you'll see the V_AUTH_CODE value
insert into bp_auth_code (bn, code) values(v_bn, v_auth_code);
commit;

或在调试模式下运行表单(不要忘记设置断点!)并跟踪其执行情况。

【讨论】:

    猜你喜欢
    • 2019-08-15
    • 2021-08-19
    • 2018-02-09
    • 2012-02-17
    • 1970-01-01
    • 2018-03-28
    • 1970-01-01
    • 1970-01-01
    • 2017-09-05
    相关资源
    最近更新 更多