简体   繁体   中英

How do I set a column value before inserting a row in Derby?

I'm trying to create a rough emulation of Oracle's ORA_ROWSCN in my Derby database. I'm using Derby for unit testing so that a tester doesn't have to install Oracle Express or something like that. So I have a statement that looks like this:

CREATE TRIGGER 
my_table_bi NO CASCADE BEFORE 
INSERT ON my_table
REFERENCING NEW AS NEW
FOR EACH STATEMENT MODE DB2SQL
NEW.ORA_ROWSCN = 1

I eventually want to make this more complex, but I'd like to start with making it even possible. I get an error saying

Syntax error: Encountered "NEW" at line 6, column 5

What am I missing? Is this even possible?

I use this to simulate a before insert, may be it will help you if it isn't too late.

DROP TRIGGER TRI_UPPER_FIRSTNAME_PERSONNES;
CREATE TRIGGER TRI_UPPER_FIRSTNAME_PERSONNES
AFTER INSERT ON PERSONNES
REFERENCING NEW AS NEW
FOR EACH ROW
UPDATE PERSONNES SET FIRSTNAME_PER = UPPER(NEW.FIRSTNAME_PER) WHERE NEW.SID_PER = SID_PER;

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.

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