ORA-00947:没有足够的价值观

时间:2013-10-29 03:56:17

标签: oracle stored-procedures plsql ora-00947

我知道这是一个新手问题,但我真的不知道我的手术有什么问题,有人可以帮帮我吗?

CREATE OR REPLACE PROCEDURE PRC_COPIA_ITEM_LOCACAO
IS
TYPE TP_LOC_ITEM_BKP
IS
  TABLE OF LOC_ITEM_LOCACAO%ROWTYPE;
  LOC_BKP TP_LOC_ITEM_BKP;
BEGIN
  SELECT * BULK COLLECT INTO LOC_BKP FROM LOC_ITEM_LOCACAO;
  FORALL X IN LOC_BKP.FIRST..LOC_BKP.LAST
    INSERT INTO LOC_ITEM_LOCACAO_BKP  VALUES (LOC_BKP(X));
  DBMS_OUTPUT.PUT_LINE('Total de linha: ' || TO_CHAR(SQL%ROWCOUNT));

END;

2 个答案:

答案 0 :(得分:2)

您需要提及列名称:

CREATE OR REPLACE PROCEDURE PRC_COPIA_ITEM_LOCACAO
IS
TYPE TP_LOC_ITEM_BKP
IS
  TABLE OF LOC_ITEM_LOCACAO%ROWTYPE;
  LOC_BKP TP_LOC_ITEM_BKP;
BEGIN
  SELECT * BULK COLLECT INTO LOC_BKP FROM LOC_ITEM_LOCACAO;
  FORALL X IN LOC_BKP.FIRST..LOC_BKP.LAST
    INSERT INTO LOC_ITEM_LOCACAO_BKP  VALUES (LOC_BKP(X).column_name1, LOC_BKP(X).column_name2 );
  DBMS_OUTPUT.PUT_LINE('Total de linha: ' || TO_CHAR(SQL%ROWCOUNT));

END;
/

Know more here

答案 1 :(得分:0)

如果您使用记录类型进行插入,则省略括号:

  FORALL X IN LOC_BKP.FIRST..LOC_BKP.LAST
    INSERT INTO LOC_ITEM_LOCACAO_BKP VALUES LOC_BKP(X);