Keeper of the Grove
Keeper of the Grove

Reputation: 140

MonetDB BEFORE INSERT TRIGGERs are just not working and I need some hlep to sort it out

in the MonetDB docs there is a simple "AFTER UPDATE" trigger example:

https://www.monetdb.org/Documentation/SQLreference/Triggers

That one works, but I tried to change this to a BEFORE INSERT, and FOR EACH ROW:

create the table:

CREATE TABLE t1 (id INT, name VARCHAR(1024));

Insert some values:

INSERT INTO t1 VALUES(10, 'monetdb');

INSERT INTO t1 VALUES(20, 'monet');

create the trigger:

CREATE TRIGGER test5 BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t1 VALUES(4, 'update_when_statement_true');

Insert some stuff to check the trigger functionality:

INSERT INTO t1 SELECT * FROM t1;

Select some stuff to see what happened:

SELECT * FROM t1; Results:

+------+---------+ | id | name | +======+=========+ | 10 | monetdb | | 20 | monet | | 10 | monetdb | | 20 | monet | +------+---------+

So basically nothing happened that I can tell with the trigger. I have tried all kinds of things in the trigger like BEGIN ATOMIC...END, calling a procedure that inserts that row, using functions and nothing I find has worked.

What the bad part is is that this is not even close to what I want to accomplish with a before insert trigger, this is just seeing if I can get it to work. The thing I really want to do is catch a row and insert it into another table if I don't like some of the values. I do this in postgres already, and I am evaluating if MonetDB can give me similar functionality. Many Thanks.

Upvotes: 1

Views: 105

Answers (1)

mkersten
mkersten

Reputation: 714

Thx. It seems like a bug. The trigger is properly called when inserting a single row. Please sent the full report to [email protected] and individual cases to the bugtracker.

Upvotes: 1

Related Questions