Trigger to Concatenate
Hello, I'm having trouble with one of my triggers. It's supposed to add the date to the beginning of an entry before it is inserted into the database.
My table name is UserBlog with columns blogEntryID(INTEGER), username(VARCHAR2(20)), blogEntryDate(DATE), blogEntryTitle(VARCHAR2(50)), blogEntry(VARCHAR2(500)).
Here's what hasn't worked:
CREATE OR REPLACE TRIGGER bfInsert_userblog
BEFORE INSERT on UserBlog
FOR EACH ROW
--sequence set up to auto-increment primary key
SELECT seq_blogEntryID.NEXTVAL into :NEW.blogEntryID from DUAL;
--append date to beginning of user's entry
:NEW.blogEntry := to_char(sysdate, "Mon. DD, YYYY: ") || :NEW.blogEntry;
I also tried
:NEW.blogEntry := CONCAT(to_char(sysdate, "Mon. DD, YYYY: "), :NEW.blogEntry);
....amongst other things like declaring the to_char(date) into a variable and likewise with :NEW.blogEntry but I keep getting compilation errors.
This is a homework assignment so it has to be done via a before insert trigger so please keep solutions within that frame please. Thanks.
Click Here to Expand Forum to Full Width