What are triggers and how do they work?

Results 1 to 4 of 4

Thread: What are triggers and how do they work?

  1. #1
    Cable Guest

    Default What are triggers and how do they work?

    Any idea when to use a trigger and what they are used for?

  2. #2
    Hugo Mejia Guest

    Default RE: What are triggers and how do they work?

    Triggers are a mechanism that some databases (DBMS) have (ie SQL Server, Sybase, Oracle), that could more or less be equated with events. Normally, when an operation such as the addition, deletion, or modification of a record occurs, one of these events will be triggered (hence the name &#039triggers&#039). These are trappable events that a developer has the ability to code, depending on the needs of the database. As an example, a programmer could add code in an update trigger on a table to keep track of users who make changes to that table. Once the code has been added, the code is run automatically every time a record on the one table is modified.<BR><BR>I hope this helps, at least a little...<BR>

  3. #3
    Cable Guest

    Default RE: What are triggers and how do they work?

    Yes it does. If I where to create a trigger in SQL Server, I could check for Null values, right?<BR><BR>For example:<BR><BR>Create TRIGGER dbo.PrintNotice<BR>ON dbo.tbl_notices<BR>FOR Insert, Update<BR>AS<BR>IF (SELECT IsNull(description,&#039&#039) from dbo.tbl_notices) = &#039&#039<BR> RAISEERROR 50001 "Cannot have a blank description"<BR><BR>On every Update and Insert, it would check to see if the description field is Null or Blank. This is valid, right?

  4. #4
    Hugo Mejia Guest

    Default RE: What are triggers and how do they work?

    Of Course!<BR>The main thing you need to do is make sure your syntax is right, although normally, if it is not, you won&#039t be able to save the code back to the DBMS.<BR>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •