Unix Technical Forum

Error on trigger since change from odbc to udl

This is a discussion on Error on trigger since change from odbc to udl within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> Hi, I have a table with possible references to itself en I use a trigger on delete to delete ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > MS SQL ODBC

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 08:26 PM
Arvid
 
Posts: n/a
Default Error on trigger since change from odbc to udl

Hi,

I have a table with possible references to itself en I use
a trigger on delete to delete those records that refere to
the one that is deleted (all in the same table) The
trigger looks like this:

CREATE TRIGGER TDSDOPDR ON dbo.SDOPDR
FOR DELETE
AS

DECLARE @pk float
DECLARE @fkVENA float

select @fkVENA = fkBHVENA_OPDRref from deleted
select @pk = pkSDOPDRref from deleted

IF @fkVENA > 0
begin
raiserror ('Kan niet verwijderen : de opdracht is reeds
aangerekend/gevorderd.',16,16)
rollback transaction
end

IF not EXISTS (select * from SDOPDR where
(fkSDOPDR_OPDRref_master=@pk or
fkSDOPDR_OPDRref_uitsplVanN0=@pk) and fkBHVENA_OPDRref > 0)
begin
delete from SDOPDR where fkSDOPDR_OPDRref_master=@pk or
fkSDOPDR_OPDRref_uitsplVanN0=@pk
end
else
raiserror ('Kan niet verwijderen : een van de opdrachten
van dit plan is reeds aangerekend/gevorderd.',16,16)


The problem occurs with the last delete statement. The
strange thing is that it deletes what it should delete,
but you get an errormessage
you get when there is nothing to delete!!: row cannot be
located for updating. Some values may have been changed
since it was last read.
you get another errormassage when there is something to
delete : Key column information is insufficient or
incorrect. Too many rows were affected by update.

If I remove the delete statement in the trigger there are
no messages. When it is there it deletes the right things
but you get those annoying messages.

any suggestions?

Arvid
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 08:27 PM
Michael Shao [MSFT]
 
Posts: n/a
Default RE: Error on trigger since change from odbc to udl

Hi Arvid,

Please try to add the statement SET NOCOUNT ON to the trigger.

When SET NOCOUNT is ON, the count (indicating the number of rows affected
by a Transact-SQL statement) is not returned.

For additional information regarding SET NOCOUNT, please refer to the
following article on SQL Server Books Online:
Topic: "SET NOCOUNT"

Please feel free to let me know if this solves your problem or if you would
like further assistance.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 08:27 PM
Arvid
 
Posts: n/a
Default RE: Error on trigger since change from odbc to udl

Thank you, it works great

Arvid


>-----Original Message-----
>Hi Arvid,
>
>Please try to add the statement SET NOCOUNT ON to the

trigger.
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:39 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com