EDIT: Per request here is what’s happening in SQL*Plus
EDIT 2: The issue was the column name being a keyword
SQL> drop table comments;
Table Dropped.
SQL> create table comments (
2 comment_id number not null,
3 post_id number not null,
4 user_id number not null,
5 message varchar2(2500) not null,
6 timestamp timestamp(6) not null);
Table Created
SQL> create sequence comment_seq
2 start with 1
3 increment by 1
4 nomaxvalue;
Sequence Created
SQL> ed
Wrote file afiedt.buf //NOTEPAD OPENED UP
1 create or replace trigger comment_trigger
2 before insert on comments
3 for each row
4 begin
5 select comment_seq.nextval
6 into :new.comment_id
7 from dual;
8 end;
SQL> /
ERROR at Line 2:
ORA-06552: PL/SQL: Compilation unit analysis terminated
ORA-06553: PLS-320: the declaration of the type of this expression is
incomplete or malformed
SQL> show errors
No errors.
Assuming I correct the data types of the numeric columns (
number(300)is not a valid data type), that code seems to work for me. If you’re getting an error, that implies that you are doing something other than what you’ve posted here.