Create trigger not firing via ODBC

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack

    Create trigger not firing via ODBC

    I created a trigger in the "source table" that will "feed" and second
    table. The trigger is as follows:
    CREATE TRIGGER [FeedToP21] ON dbo.FromUPS
    FOR INSERT
    AS
    Declare @Count int

    Select @Count = Count(*) from Inserted
    If @Count > 0
    Begin
    Insert into ToP21
    Select i.* From Inserted i
    Left Join ToP21 t
    on i.recnum = t.recnum
    Where t.recnum is null
    End

    If @@ERROR != 0
    Rollback Tran

    A record was created in the "source table" via ODBC, however, the
    trigger does not seem to have fired to create the record in the second
    table.
    If I create a record manually using SQL Server Enterprise Manager
    within the "tableview" the trigger fires and a duplicate record is
    created in the second table.

    Is there a fix for this problem?

    Thank you in advance.
  • John Bell

    #2
    Re: Create trigger not firing via ODBC

    Hi

    There is not enough detail to say why this is not being called and how the
    transactions are being handled and what data is not being written.

    You may want to use profiler to check the calls and possible save your
    commands to a sql script that can be run in Query Analyser. You could use
    Raiserror instead of rolling back the transaction to see if that condition
    is reached or to return debug information.

    John





    "Jack" <jackso95@hotma il.com> wrote in message
    news:ba6102e.03 11131522.4c8991 1@posting.googl e.com...[color=blue]
    > I created a trigger in the "source table" that will "feed" and second
    > table. The trigger is as follows:
    > CREATE TRIGGER [FeedToP21] ON dbo.FromUPS
    > FOR INSERT
    > AS
    > Declare @Count int
    >
    > Select @Count = Count(*) from Inserted
    > If @Count > 0
    > Begin
    > Insert into ToP21
    > Select i.* From Inserted i
    > Left Join ToP21 t
    > on i.recnum = t.recnum
    > Where t.recnum is null
    > End
    >
    > If @@ERROR != 0
    > Rollback Tran
    >
    > A record was created in the "source table" via ODBC, however, the
    > trigger does not seem to have fired to create the record in the second
    > table.
    > If I create a record manually using SQL Server Enterprise Manager
    > within the "tableview" the trigger fires and a duplicate record is
    > created in the second table.
    >
    > Is there a fix for this problem?
    >
    > Thank you in advance.[/color]


    Comment

    Working...