MySql 5.0 - Trigger with Bussiness Logic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crs27
    New Member
    • Jul 2007
    • 40

    MySql 5.0 - Trigger with Bussiness Logic

    Hai,

    I would like to know if i can include bussiness logic in Trigger.

    For Example:

    On a insert/update on a table(primary) i want to insert values to other table(secondary ).

    A insert is done on a primary table only when their are no records present w.r.t the id .If the id is present in the table an update action is performed.
    I will have to check if the id is present or not.But not getting to know how to implement it in trigger.

    Thank You,
    Sindhu
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    Triggers can not use dynamic SQL statements. You would have to use a procedure or a function to do this.

    Note that you can not call procedures or functions that use dynamic SQL statements from a trigger either.

    I would recommend simply adding a "AddUser" or "AddClient" procedure to your database that you would call rather than adding data using the INSERT statement.
    That way you can add whatever logic you want before you insert anything.

    Comment

    Working...