ORA-00947 : Not Enough Values

11.4k views Asked by At

I know this is a newbie question, but I really don't know what is wrong with my procedure, can anyone help me?

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

There are 2 answers

0
ajmalmhd04 On BEST ANSWER

You need to mention the column names :

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

0
Jeffrey Kemp On

If you're inserting using a record type, you omit the parentheses:

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