【问题标题】:Oracle PLS-00382: expression is of wrong type 06550Oracle PLS-00382:表达式类型错误 06550
【发布时间】:2015-03-03 06:09:03
【问题描述】:

我正在尝试使用从我的选择中检索到的 id 值,它是我的循环在我的插入语句中所基于的值。来自 select 的 id 和 TEST_LOG 表中的第二列都是 NUMBER(19,0)。当我用 12345 替换 id 时,它工作正常。有什么想法吗?

BEGIN
  FOR id IN
  (SELECT id FROM t_sample where children is null)
  LOOP
    INSERT INTO TEST_LOG VALUES (my_sequence.nextVal, id, 'sample', current_timestamp);
  END LOOP;
END;

错误:

Error starting at line : 6 in command -
BEGIN
      FOR id IN
      (SELECT id FROM t_sample where children is null)
      LOOP
        INSERT INTO TEST_LOG VALUES (my_sequence.nextVal, id, 'sample', current_timestamp);
      END LOOP;
    END;
Error report -
ORA-06550: line 5, column 69:
PLS-00382: expression is of wrong type
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

【问题讨论】:

  • Id 应在插入中称为id.id

标签: oracle


【解决方案1】:

这种混乱是可以理解的。 最好这样写,错误就会发光。

...
FOR record IN
      (SELECT id FROM t_sample where children is null)
      LOOP
        INSERT INTO TEST_LOG VALUES (my_sequence.nextVal, record.id, 'sample', current_timestamp);
      END LOOP;
...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-29
    • 1970-01-01
    • 2021-01-08
    • 1970-01-01
    • 2021-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多