oracle-databaseplsqlora-00984

ORA-00984: column not allowd here on procedure with input variables


I seem to get ORA-00984 error when inserting the inputs to the sql statment
PLSQL code:

CREATE OR REPLACE PROCEDURE do_insättning (pnr_in in insättning.pnr%type, 
                                       knr_in in insättning.knr%type,
                                       belopp_in in insättning.belopp%type,
                                       datum_in in insättning.datum%type)
IS 
BEGIN
 INSERT INTO insättning 
 VALUES (radnr_seq,pnr_in,knr_in,belopp_in,datum_in);
END;

The design of the table:
Table design

Also the radnr_seq:

CREATE SEQUENCE radnr_seq START WITH 1 INCREMENT BY 1;

What I have tried is to check is that the sql statemtn only inserts to one column like this:

INSERT INTO insättning (radnr) values (radnr_seq);

Aswell as checking for invalid values but to no result.


Solution

  • You need to call nextval for sequence :

    CREATE OR REPLACE PROCEDURE do_insättning (pnr_in in insättning.pnr%type, 
                                       knr_in in insättning.knr%type,
                                       belopp_in in insättning.belopp%type,
                                       datum_in in insättning.datum%type)
    IS 
    BEGIN
     INSERT INTO insättning 
     VALUES (radnr_seq.NEXTVAL,pnr_in,knr_in,belopp_in,datum_in);
    END;