Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reading uncommitted data
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01426495
Message ID:
01426515
Views:
48
Hi Hugo,

Maybe I'm missing something but it looks like you're trying to get data from the record that has not been inserted yet. Isn't it the one you're creating in the trigger?
Can you describe what're you trying to do?


>Sorry Sergey, I misnamed them, they are actually two scalar functions, my bad.
>
>Also I forgot to post the code for the important one, as it is the one that uses the same table that is being inserted
>
>
>USE [TVM]
>GO
>/****** Object:  UserDefinedFunction [dbo].[getClearedEventFaultsLogPK]    Script Date: 09/28/2009 12:18:24 ******/
>SET ANSI_NULLS ON
>GO
>SET QUOTED_IDENTIFIER ON
>GO
>-- =============================================
>-- Author:		RAN02
>-- Create date: 2009-09-27
>-- Description:	Returns the PK from FaultsLog for an event that was cleared
>-- =============================================
>ALTER FUNCTION [dbo].[getClearedEventFaultsLogPK] 
>(
>	@iEventPK int,
>	@iDevicePK int
>)
>RETURNS int
>AS
>BEGIN
>	-- Declare the return variable here
>	DECLARE @iFKFaultsLog int
>
>	-- Add the T-SQL statements to compute the return value here
>	SET @iFKFaultsLog =	(
>							SELECT TOP 1
>										FL.PK
>								FROM	TVM.dbo.FaultsLog FL
>								JOIN	TVM.dbo.EventsLog EL ON FL.fkEventsLog = EL.PK
>								WHERE	EL.fkEventDefinitions = @iEventPK and EL.SetFlag = 1 and FL.fkDevices = @iDevicePK
>								ORDER	BY EL.Created DESC
>						)
>
>	-- Return the result of the function
>	RETURN @iFKFaultsLog
>
>END
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform