Can't use NEW keyword in trigger

Ivan Smahin ivan_smahin at paradigmasoft.com
Tue Aug 27 23:20:34 CDT 2013


On Aug 28, 2013, at 5:02 AM, Brenda Bell <bb31l at theotherbell.com> wrote:

> I have a simple trigger that looks like this:
> 
> CREATE TRIGGER "trigger_yarn_compute_weight_grams"
> 	BEFORE INSERT
> 	ON "yarn"
> 	FOR EACH ROW
> 	WHEN weight_grams = 0
> BEGIN
> NEW.weight_grams = NEW.weight_ounces * 28.3495
> END;


Ups, it seems you forget ";" at the end of "NEW.weight_grams = NEW.weight_ounces * 28.3495".

So it should be:

CREATE TRIGGER "trigger_yarn_compute_weight_grams"
	BEFORE INSERT
	ON "yarn"
	FOR EACH ROW
	WHEN weight_grams = 0
BEGIN
NEW.weight_grams = NEW.weight_ounces * 28.3495;
END;


-- 
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina-studio mailing list