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

129 views Asked by At

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.

2

There are 2 answers

2
Camille On BEST ANSWER

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;
0
RJ7 On

You need to insert the sequence number nextval radnr_seq.nextval.