0

I'm trying to create a trigger in Oracle, but it's returning the error

ORA-00942: table or view does not exist

Here is the table:

CREATE TABLE quartos(
    idQuarto NUMBER(11), 
    numeroQ NUMBER(11), 
    limitePessoas NUMBER(2), 
    valorDiaria NUMBER(10,2), 
    situacao NUMBER(1), CONSTRAINT idQuarto_pk PRIMARY KEY (idQuarto)
);

Here is the sequence:

CREATE sequence "quartos_seq";

And here is the trigger:

CREATE trigger "bi_quartos"
  before insert on "quartos"
  for each row
begin
  select "quartos_seq".nextval into :NEW."idQuarto" from dual;
end;

I've creatend another trigger before the same way and nothing went wrong. I just changed the parameters and now its returning that error

Ruan Molinari
  • 99
  • 3
  • 10

2 Answers2

0

remove the double quotes from

CREATE trigger "bi_quartos" before insert on "quartos"


Tables names are converted to upper case. What you are doing is forcing it to search a table with lower case which doesn't exist.

Adnan Bhatti
  • 3,410
  • 4
  • 25
  • 38
0

You're mixing case sensitive and case insensitive identifiers for your table and column names.

If you don't wrap the original declarations in double-quotes, the are created as case insensitive and you can't use double-quotes when you try and use them:

CREATE or replace trigger "bi_quartos" before insert on quartos for each row begin select "quartos_seq".nextval into :new.idQuarto from dual; end;

Starfighter
  • 151
  • 5