RE: After Insert Trigger
Posted in 1998
----------
From: Michael Segel[SMTP:mikey@segel.NO.SPAM.KINGOFMYDOMAIN.SPAM.NO.com]
Sent: Monday, February 09, 1998 5:28 PM
Leffler, Jonathan wrote:
> JL: That on its own is not sufficient. You also have to ensure that the INSERT statement
> does not specify the LastUpdated and ByWhom columns. This typically means either you
> INSERT through a view which excludes those columns:
>
> CREATE VIEW ins_tablename (col1, ..., colN) AS
> SELECT col1, ..., colN
> FROM tablename;>
> Note that colN excludes LastUpdated and ByWhom... Or you specify the column list in the
> INSERT statement:
>
> INSERT INTO tablename(col1, ..., colN)
> VALUES (val1, ..., valN);>
> This allows the DEFAULT for the columns to take effect; if a value is specified for the column,
> that value is inserted, regardless of the defaults.
>
>
Uhmm,
Hate to nitpick, but isn't that the prefered method of writing
the inserts? (Like part of the recommended coding standards?)
JL: Yes, it is a coding standard. But, in my experience, it is one of the standards
which is more frequently violated - and I plead guilty to violating it, too, and not
just occasionally.
Independently of whether or not it is an abused standard, it is necessary to omit
a value for the defaulted columns to get the defaults to take. Supplying NULL in
any shape or form doesn't count, either.
But I think we're basically in agreement... :-)
Yours,
Jonathan Leffler (jleffler@visa.com) #include <bother.antispamming.h>