简体   繁体   English

通过触发器自动填充描述列

[英]Auto-populate the description column through trigger

I would like to auto-populate the description column through trigger but I'm stuck in the inserting part, here is my code:我想通过触发器自动填充描述列,但我卡在插入部分,这是我的代码:

CREATE OR REPLACE TRIGGER "INSERT_MESSAGE" AFTER INSERT, UPDATE ON "A"
FOR EACH ROW
BEGIN
    SELECT "SEQ_A".NEXTVAL INTO :NEW.MESSAGE FROM DUAL
END;
/

There is a table "A" which has a column "MESSAGE", and the message will be generated into that column with a specific format: "Hi how are you?"有一个表“A”,其中有一列“MESSAGE”,消息将以特定格式生成到该列中:“嗨,你好吗?” How can I generate this text into that column when the trigger is activated?当触发器被激活时,如何将此文本生成到该列中? Thank you.谢谢你。

Logically you cannot change something after it's happened and there are a few syntax issues with your code.从逻辑上讲,您无法在事情发生后进行更改,并且您的代码存在一些语法问题。 Try尝试

CREATE OR REPLACE TRIGGER "INSERT_MESSAGE" before INSERT or UPDATE ON "A" 
FOR EACH ROW 
BEGIN 
SELECT “SEQ_A”.NEXTVAL INTO :NEW.MESSAGE FROM DUAL ;
END;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM