So I have this University assignment in which I have to create a trigger called bill_overdue. When a row that has status = overdue is inserted into table invoice, a row is inserted into another table called message.
CREATE SEQUENCE AUTOINCREMENTMESSAGE
MINVALUE 100
START WITH 101
INCREMENT BY 1
CACHE 10
;
CREATE OR REPLACE TRIGGER BILL_OVERDUE
BEFORE INSERT ON INVOICE
FOR EACH ROW
WHEN (NEW.STATUS = 'Overdue')
BEGIN
INSERT INTO MESSAGE (MESSAGENO,MESSAGEDATE,ORIGIN,MESSAGE)
VALUES (AUTOINCREMENTMESSAGE.nextval,SYSDATE,USER,:NEW.DATEISSUED,:NEW.INVOICENO,:NEW.CAMPAIGNTITLE);
END;
/
Now as you can see I want to add :new.dateissued
, :new.invoiceno
and :new.campaigntitle
into a single field( message
).Now I know that what I have done is wrong but I've tried adding parentheses around it etc and nothing seems to do what I want. How do I get this to work? Is it possible to do what I want or have I got it completely wrong?
您可以使用串联
:new.dateissued || ', ' || :new.invoiceno || ', ' || :new.campaigntitle
For Oracle you can also concatenate using the CONCAT()
function and you can try
CONCAT(:NEW.DATEISSUED,:NEW.INVOICENO,:NEW.CAMPAIGNTITLE)
You may have to cast/convert some of those values though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.