DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Can trigger be used on select item from a table?

  1. #1
    Melanie Guest

    Can trigger be used on select item from a table?




  2. #2
    Glenn Block Guest

    Re: Can trigger be used on select item from a table?

    No, triggers are on inserts, updates, and deletes only.
    However, you can use a stored procedure that will return the results of a
    select statement, and that contains the code that you want to run when
    selecting.

    e.g.

    create procedure get_data
    @key int
    as
    --get the data
    select * from t_Table where key = @key

    --log that someone retrieved the data
    --log table contains key field and date field
    insert into t_Log values (@key, getdate())
    go

    This procedure selects a record and then inserts a log record.
    you could use a similair model.

    --Glenn

    "Melanie" <meilingw@mail.hongkong.com> wrote in message
    news:3e7c7888$1@tnews.web.devx.com...
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center