This is a discussion on SQL2K Trigger problem within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> I've got a problem with a trigger I've set on a table. This is the code for the trigger: ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I've got a problem with a trigger I've set on a table. This is the code for the trigger: CREATE TRIGGER Update_Allowance_Rule ON [dbo].[setting_allowance_rule] FOR UPDATE AS UPDATE [dbo].[setting_allowance_condition_rule] SET [dbo].[setting_allowance_condition_rule].rule_description = deleted.rule_description WHERE [dbo].[setting_allowance_condition_rule].allowance_rule_key = deleted.allowance_rule_key The problem that I'm having is that when an update occurs on the setting_allowance_rule the trigger fires but I get the following ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'dbo.setting_allowance_condition_rule' setting_allowance_condition_rule does exist, the spelling is correct and it is owned by dbo. The version of the SQL Server ODBC driver is 2000.81.9030.04. For the life of me, I can't see what I've done wrong. Have I done something stupid? Any help anyone can offer will be greatly appreciated. Thanks Joe Bertolini |
| |||
| You can update other tables from triger, use UPDATE [dbo].[setting_allowance_condition_rule] SET rule_description = deleted.rule_description FROM [dbo].[setting_allowance_condition_rule] inner join deleted on [dbo].[setting_allowance_condition_rule].allowance_rule_key = deleted.allowance_rule_key and if that fails check if setting_allowance_condition_rule really exists. KR "Joe Bertolini" <Joe.Bertolini@bgc-contracting.com.au> wrote in message news:Odh13vGQDHA.2160@TK2MSFTNGP11.phx.gbl... > I've got a problem with a trigger I've set on a table. This is the code for > the trigger: > > CREATE TRIGGER Update_Allowance_Rule ON [dbo].[setting_allowance_rule] > FOR UPDATE > AS > UPDATE [dbo].[setting_allowance_condition_rule] > SET [dbo].[setting_allowance_condition_rule].rule_description = > deleted.rule_description > WHERE [dbo].[setting_allowance_condition_rule].allowance_rule_key = > deleted.allowance_rule_key > > The problem that I'm having is that when an update occurs on the > setting_allowance_rule the trigger fires but I get the following ODBC error: > > [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name > 'dbo.setting_allowance_condition_rule' > > setting_allowance_condition_rule does exist, the spelling is correct and it > is owned by dbo. The version of the SQL Server ODBC driver is > 2000.81.9030.04. For the life of me, I can't see what I've done wrong. Have > I done something stupid? Any help anyone can offer will be greatly > appreciated. > > Thanks > > > Joe Bertolini > > |
| |||
| Joe, first check a table called 'dbo.setting_allowance_condition_rule' exists. Then try adding a from clause, "FROM dbo.setting_allowance_condition_rule, deleted" "Joe Bertolini" <Joe.Bertolini@bgc-contracting.com.au> wrote in message news:Odh13vGQDHA.2160@TK2MSFTNGP11.phx.gbl... > I've got a problem with a trigger I've set on a table. This is the code for > the trigger: > > CREATE TRIGGER Update_Allowance_Rule ON [dbo].[setting_allowance_rule] > FOR UPDATE > AS > UPDATE [dbo].[setting_allowance_condition_rule] > SET [dbo].[setting_allowance_condition_rule].rule_description = > deleted.rule_description > WHERE [dbo].[setting_allowance_condition_rule].allowance_rule_key = > deleted.allowance_rule_key > > The problem that I'm having is that when an update occurs on the > setting_allowance_rule the trigger fires but I get the following ODBC error: > > [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name > 'dbo.setting_allowance_condition_rule' > > setting_allowance_condition_rule does exist, the spelling is correct and it > is owned by dbo. The version of the SQL Server ODBC driver is > 2000.81.9030.04. For the life of me, I can't see what I've done wrong. Have > I done something stupid? Any help anyone can offer will be greatly > appreciated. > > Thanks > > > Joe Bertolini > > |
| ||||
| Thanks for your reply. Unfortunately neither suggestion worked and dbo.setting_allowance_condition_rule definitely does exist. Guess I'll just have to kludge in code in the front end app, Yuk! Thanks anyway. "Kresimir Radosevic" <kresimir.radosevic@zg.tel.hr> wrote in message news:u0DdoLHQDHA.2316@TK2MSFTNGP11.phx.gbl... > You can update other tables from triger, use > > UPDATE [dbo].[setting_allowance_condition_rule] > SET rule_description = deleted.rule_description > FROM [dbo].[setting_allowance_condition_rule] inner join deleted on > [dbo].[setting_allowance_condition_rule].allowance_rule_key = > deleted.allowance_rule_key > > and if that fails check if setting_allowance_condition_rule really exists. > > KR > > "Joe Bertolini" <Joe.Bertolini@bgc-contracting.com.au> wrote in message > news:Odh13vGQDHA.2160@TK2MSFTNGP11.phx.gbl... > > I've got a problem with a trigger I've set on a table. This is the code > for > > the trigger: > > > > CREATE TRIGGER Update_Allowance_Rule ON [dbo].[setting_allowance_rule] > > FOR UPDATE > > AS > > UPDATE [dbo].[setting_allowance_condition_rule] > > SET [dbo].[setting_allowance_condition_rule].rule_description = > > deleted.rule_description > > WHERE [dbo].[setting_allowance_condition_rule].allowance_rule_key = > > deleted.allowance_rule_key > > > > The problem that I'm having is that when an update occurs on the > > setting_allowance_rule the trigger fires but I get the following ODBC > error: > > > > [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name > > 'dbo.setting_allowance_condition_rule' > > > > setting_allowance_condition_rule does exist, the spelling is correct and > it > > is owned by dbo. The version of the SQL Server ODBC driver is > > 2000.81.9030.04. For the life of me, I can't see what I've done wrong. > Have > > I done something stupid? Any help anyone can offer will be greatly > > appreciated. > > > > Thanks > > > > > > Joe Bertolini > > > > > > |