【问题标题】:ORA-01461: can bind a LONG value only for insert into a LONG column-Occurs when compiling a JobORA-01461: 只能绑定 LONG 值以插入 LONG 列 - 编译作业时发生
【发布时间】:2016-05-07 00:17:01
【问题描述】:
               DECLARE
               X           NUMBER := 960004;
               user_name   VARCHAR2 (30);
            BEGIN
               SELECT USER INTO user_name FROM DUAL;

               EXECUTE IMMEDIATE 'alter session set current_schema = EC_ADMIN';

               BEGIN
                  SYS.DBMS_JOB.iSUBMIT (
                     job         => X,
                     what        => 'DECLARE
               p_error_text                VARCHAR2 (4000);
               p_exec_status               VARCHAR2 (50);
               l_error_source_s   CONSTANT VARCHAR2 (30) := ''JOB# 960004'';
               l_sql_point_n               NUMBER;
               l_err_text_s                VARCHAR2 (4000);


---cursor to fetch the inventory_item_id, organization_id----

               CURSOR c_system_item
               IS
            SELECT inventory_item_id, organization_id
              FROM xx_mtl_system_items_b
            WHERE tc_processed_status = ''N''
            UNION
            SELECT xmic.inventory_item_id, xmic.organization_id
              FROM xx_mtl_item_categories xmic
            WHERE     EXISTS
                          (SELECT 1
                             FROM xx_mtl_system_items_b xmsib
                            WHERE     xmsib.organization_id = xmic.organization_id
                                  AND xmsib.inventory_item_id = xmic.inventory_item_id)
                   AND tc_processed_status = ''N''
            UNION
            SELECT xemsieb.inventory_item_id, 1 AS organization_id
              FROM xx_ego_mtl_sy_items_ext_b xemsieb
            WHERE     EXISTS
                          (SELECT 1
                             FROM xx_mtl_system_items_b xmsib
                            WHERE xmsib.inventory_item_id = xemsieb.inventory_item_id)
                   AND tc_processed_status = ''N''
                   AND attr_group_id = 591;

------------------cursor ends-----------


            BEGIN
               FOR system_item_rec IN c_system_item
               LOOP
                  BEGIN
                     l_sql_point_n := 10;
                     xx_mtl_system_items_b_proc (system_item_rec.inventory_item_id,
                                                 system_item_rec.organization_id,
                                                 p_error_text,
                                                 p_exec_status);
                     l_sql_point_n := 20;

                     IF p_exec_status = ''SUCCESS''
                     THEN
                        l_sql_point_n := 30;

                        UPDATE xx_mtl_system_items_b
                           SET tc_processed_status = ''Y'', tc_processed_date = SYSDATE
                         WHERE inventory_item_id = system_item_rec.inventory_item_id
                               AND organization_id = system_item_rec.organization_id;

                        l_sql_point_n := 40;

                        UPDATE xx_mtl_item_categories
                           SET tc_processed_status = ''Y'', tc_processed_date = SYSDATE
                         WHERE inventory_item_id = system_item_rec.inventory_item_id
                               AND organization_id = system_item_rec.organization_id;

                        l_sql_point_n := 41;

                        UPDATE XX_EGO_MTL_SY_ITEMS_EXT_B
                           SET tc_processed_status = ''Y'', tc_processed_date = SYSDATE
                         WHERE inventory_item_id = system_item_rec.inventory_item_id
                               AND attr_group_id = 591;




                     ELSIF p_exec_status = ''FAILURE''
                     THEN
                        l_sql_point_n := 50;

                        UPDATE xx_mtl_system_items_b
                           SET tc_processed_status = ''E'', tc_processed_date = SYSDATE
                         WHERE inventory_item_id = system_item_rec.inventory_item_id
                               AND organization_id = system_item_rec.organization_id;

                        l_sql_point_n := 60;

                        UPDATE xx_mtl_item_categories
                           SET tc_processed_status = ''E'', tc_processed_date = SYSDATE
                         WHERE inventory_item_id = system_item_rec.inventory_item_id
                               AND organization_id = system_item_rec.organization_id;

                        l_sql_point_n := 61;                   

                        UPDATE XX_EGO_MTL_SY_ITEMS_EXT_B
                           SET tc_processed_status = ''E'', tc_processed_date = SYSDATE
                         WHERE inventory_item_id = system_item_rec.inventory_item_id
                               AND attr_group_id = 591;                   

                     END IF;

                     l_sql_point_n := 70;
                     COMMIT;
                  EXCEPTION
                     WHEN OTHERS
                     THEN
                        ROLLBACK;
                        l_err_text_s :=
                              ''Error Ocured In : ''
                           || l_error_source_s
                           || '' At SQL Point : ''
                           || l_sql_point_n
                           || '' ERROR : ''
                           || SUBSTR (SQLERRM (SQLCODE), 1, 250);

                        xx_log_dbms_error (''E'',
                                           ''Inventory_Item_Id'',
                                           system_item_rec.inventory_item_id,
                                           NULL,
                                           l_err_text_s,
                                           USER,
                                           l_error_source_s);
                  END;
               END LOOP;
            END;',
                     next_date   => SYSDATE,
                     interval    => 'SYSDATE + 45/1440',
                     no_parse    => FALSE);
                  SYS.DBMS_OUTPUT.PUT_LINE ('Job Number is: ' || TO_CHAR (x));

                  EXECUTE IMMEDIATE 'alter session set current_schema = ' || user_name;
               EXCEPTION
                  WHEN OTHERS
                  THEN
                     EXECUTE IMMEDIATE 'alter session set current_schema = ' || user_name;

                     RAISE;
               END;

               COMMIT;
            END;
            /

给出错误
[错误] 执行 (26: 1): ORA-01461: can bind a LONG 值仅用于插入 LONG 列 ORA-06512:在第 142 行

inventory_item_id、organization_id 都是数据类型 number xx_mtl_system_items_b & xx_mtl_item_categories

inventory_item_id 是 xx_ego_mtl_sy_items_ext_b 中的数据类型编号 xx_ego_mtl_sy_items_ext_b 中不存在organization_id

【问题讨论】:

  • 虽然oracle corp有mysql ab,但不代表oracle产品相关的问题应该标记为mysql!
  • 知道了,有人可以帮我吗?
  • 游标中有一个选择查询,当我运行相同的代码只是删除作业代码时,它工作正常..只有在作业内部会引发此错误
  • 是否需要手动将job_no分配给DBMS_JOB?只需将X 声明为X NUMBER; 并删除赋值并尝试。

标签: oracle oracle11g


【解决方案1】:

您正在向 DBMS_JOB.SUBMIT 提交一个 6300 个字符的字符串。根据 Oracle 版本,这可能太长了。 Oracle 有时会看到这样的长字符串并自动转换为 LONG,这是一种可憎的数据类型。 varchar2 的通常限制是 4000。我认为这就是杀死你的原因。

【讨论】:

    猜你喜欢
    • 2012-07-08
    • 2014-09-20
    • 2013-06-01
    • 2017-08-29
    • 2020-06-22
    • 1970-01-01
    • 1970-01-01
    • 2017-05-13
    • 2013-10-24
    相关资源
    最近更新 更多