January 2008
Intermediate to advanced
384 pages
8h 1m
English
This was posted by a newbie on an SQL Server newsgroup in a very different format because of the dialect not being close to ANSI Standards. While the dialect is a problem, there was another and bigger problem. The poster was still thinking in terms of procedural code and was forced by the dialect to write a CURSOR inside the body of the original trigger code to get the equivalent of a FOR EACH ROW clause. Here is my simplified literal translation, including the original flag code and error message.
CREATE TRIGGER InsertStocks BEFORE INSERT ON Portfolio REFERENCING NEW ROW AS N FOR EACH ROW IF (SELECT P.disabled_flag FROM Portfolio AS P WHERE P.stock_sym = N.stock_sym) = 1 -- uses a flag! OR (SELECT P.share_qty ...
Read now
Unlock full access