Archive

Posts Tagged ‘FireEventSp’

Calling a Synchronous Event within a SP Transaction and Handling Failure

March 20th, 2012 No comments

First, determine the current site, after which you must name a configuration, by convention:

DECLARE @Site SiteType
SELECT @Site = site FROM parms

Then determine the current SessionId:

 

DECLARE @SessionId RowPointerType
SET @SessionId = dbo.SessionIdSp()

Finally, add the procedure code:

 

BEGIN TRANSACTION
UPDATE coitem
SET due_date = dbo.CalcDueDate(@Parm1, @Parm2)
WHERE coitem.co_num = @CoNum
AND coitem.co_line = @CoLine
AND coitem.co_release = @CoRelease
SET @MyEventParmId = NEWID()
EXEC InsertEventInputParameterSp @MyEventParmId, ‘CoNum’, @CoNum
EXEC InsertEventInputParameterSp @MyEventParmId, ‘CoLine’, @CoLine
EXEC InsertEventInputParameterSp @MyEventParmId, ‘CoRelease’, @CoRelease

DECLARE
@anyHandlersFailed [tinyint],
@result [nvarchar](4000),
@Infobar [nvarchar](4000)
EXEC @Severity = FireEventSp
@eventName = SetCoitemDueDate’,
@configName = ‘SyteLine’,
@sessionID = @SessionID,
@eventTrxId = null,
@eventParmId = @MyEventParmID OUTPUT,
@transactional = 0,
@anyHandlersFailed = @anyHandlersFailed output,
@result = @result output,
@Infobar = @infobar output
IF @Severity > 0
BEGIN
EXEC RaiseError @Infobar, @Severity
ROLLBACK TRANSACTION
END

COMMIT TRANSACTION

Categories: Development, SQL Tags: ,