Oracle APEX PL/SQL 错误

Posted

技术标签:

【中文标题】Oracle APEX PL/SQL 错误【英文标题】:Oracle APEX PL/SQL Error 【发布时间】:2017-09-12 14:13:00 【问题描述】:

我有这个 PL/SQL 语句:

BEGIN
    DELETE FROM REI_RETAIL_FACTOR_PARTS P
    WHERE  DEALER_NUMBER = :P13_FILTER_DEALER;

    INSERT INTO REI_RETAIL_FACTOR_PARTS
    (
        SELECT
            RF.TEILE_NR as "PART_NR",
            :P13_OVERWRITE_VALUE as "REQUESTED_RATE",
            sysdate as "REQUEST_DATE",
            :P13_FILTER_DEALER as "DEALER_NUMBER"
        FROM REI_RETAIL_FACTOR RF
        WHERE DEALER_NUMBER = :P13_FILTER_DEALER
    );
END;

错误是:

ORA-01861: 文字与格式字符串不匹配。

这真的很令人沮丧,因为我从不尝试格式化任何东西。 那么,为什么我一直收到这个错误呢?

【问题讨论】:

听起来像是在调用一个隐含的TO_DATE。您尚未指定插入的目标列,也许您正在将非日期值之一(不是sysdate)插入到日期列中? 我想这也可能是一个隐含的TO_NUMBER True - 日期或数字列可能会像这样失败。 从选择返回的值似乎导致错误,你能用表格的 ddl 向我们展示选择的输出吗? 【参考方案1】:

ORA-01861: 文字与格式字符串不匹配。

INSERT 语法有误。可能的解决方案:

a) 定义列列表:

BEGIN
    DELETE FROM REI_RETAIL_FACTOR_PARTS P
    WHERE  DEALER_NUMBER = :P13_FILTER_DEALER;

    INSERT INTO REI_RETAIL_FACTOR_PARTS(column_name1, ...)
        SELECT
            RF.TEILE_NR as "PART_NR",
            :P13_OVERWRITE_VALUE as "REQUESTED_RATE",
            sysdate as "REQUEST_DATE",
            :P13_FILTER_DEALER as "DEALER_NUMBER"
        FROM REI_RETAIL_FACTOR RF
        WHERE DEALER_NUMBER = :P13_FILTER_DEALER;
END;

b) 删除 ()(警告!选择中的列顺序至关重要):

BEGIN
    DELETE FROM REI_RETAIL_FACTOR_PARTS P
    WHERE  DEALER_NUMBER = :P13_FILTER_DEALER;

    INSERT INTO REI_RETAIL_FACTOR_PARTS
        SELECT
            RF.TEILE_NR as "PART_NR",
            :P13_OVERWRITE_VALUE as "REQUESTED_RATE",
            sysdate as "REQUEST_DATE",
            :P13_FILTER_DEALER as "DEALER_NUMBER"
        FROM REI_RETAIL_FACTOR RF
        WHERE DEALER_NUMBER = :P13_FILTER_DEALER;
END;

【讨论】:

谢谢!列顺序不正确,我认为定义正确的名称就足够了。

以上是关于Oracle APEX PL/SQL 错误的主要内容,如果未能解决你的问题,请参考以下文章

PL/SQL 中的问题 = 错误堆栈:ORA-01403:Oracle Application Express (APEX) 中没有数据

在 Oracle APEX PL/SQL 中传递变量

运行时解析 PL/SQL 的 Oracle Apex Cards 视图

如何解决 Oracle Apex 中的无效列错误?

Oracle Apex:PL/SQL 块中的 Javascript 代码

在 oracle apex 中将 sql 查询重写为 pl/sql