Sunday, March 25, 2012

Creating a Trigger on Table Access

Hi,
I am trying to create a trigger to update a datetime field when a user
logs in to their account. Is there a way to create a trigger that
updates a field when the table is accessed? The only other possible
way I can think of to accomplish this would be to write code that
updates a field on submit so that it trips the trigger I have to update
the time. This does not seem especially efficient, though.Never update a value just to call a trigger. Create a stored procedure and
call it when you need to. This is a job for a stored procedure, called by
the application, not a job for a trigger. Triggers are used to enforce
rules on your data, and sometimes for auditing changes to data, but not for
this.
<iamalex84@.gmail.com> wrote in message
news:1148415231.372278.151590@.g10g2000cwb.googlegroups.com...
> Hi,
> I am trying to create a trigger to update a datetime field when a user
> logs in to their account. Is there a way to create a trigger that
> updates a field when the table is accessed? The only other possible
> way I can think of to accomplish this would be to write code that
> updates a field on submit so that it trips the trigger I have to update
> the time. This does not seem especially efficient, though.
>|||There is no SELECT trigger. You could have the logon process and/or table
access be done only via a stored procedure.
HTH
Vern
"iamalex84@.gmail.com" wrote:

> Hi,
> I am trying to create a trigger to update a datetime field when a user
> logs in to their account. Is there a way to create a trigger that
> updates a field when the table is accessed? The only other possible
> way I can think of to accomplish this would be to write code that
> updates a field on submit so that it trips the trigger I have to update
> the time. This does not seem especially efficient, though.
>|||Thank you both for your responses.

No comments:

Post a Comment