SQL SERVER: Altering service broker stored procedures

ε祈祈猫儿з 提交于 2019-12-25 06:29:08

问题


I cannot alter the service broker stored procedure, when I update the stored procedure it does not show any error and successfully gets updated but the changes does not come into affect.

Is it because I need to stop the queue of the service broker on both databases before the changes could come into affect?

Note: the service broker stored procedures produce and read xmls.

INCLUDING THE STORE PROCEDURE

ALTER PROCEDURE [dbo].[ServiceBroker_AtTarget_FromSLICJobEstimateDetailsNewLineAddedBySupplier]
    @XML XML(SLICMessageSchema)
AS
BEGIN
    -- extract data :
    DECLARE     
    @LogNo              INT,
    @QuoteReference         INT,
    @JobEstimatesDetailID       INT,
    @UserName           NVARCHAR(50),
    @Description            NVARCHAR(MAX),
    @UnitValue          DECIMAL(18,2),
    @Quantity           DECIMAL(18,2),
    @LineTotal          DECIMAL(18,2),
    @QuoteTotal         DECIMAL(18,2),
    @tsCreated          DATETIME

    SELECT      @QuoteReference = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@QuoteReference)[1]', 'int'),
            @JobEstimatesDetailID = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@JobEstimatesDetailID)[1]', 'int'),    
            @UserName = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@UserName)[1]', 'nvarchar(50)'),
            @Description = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@Description)[1]', 'nvarchar(max)'),
            @UnitValue = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@UnitValue)[1]', 'decimal(18,2)'),
            @Quantity = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@Quantity)[1]', 'decimal(18,2)'),      
            @tsCreated = @XML.value('data(//FromSLIC/FromSLICJobEstimateDetailsNewLineAddedBySupplier/@tsCreated)[1]', 'datetime')

    SET @LogNo = (SELECT mlq.logno FROM fsgmgtservices.dbo.maintlogquotes mlq WHERE mlq.quoteno = @QuoteReference)

    INSERT INTO fsgcentraldata.dbo.[tblSLICGeneratedEvents]
    (EventNameID, tsCreated, CreatedBy, IsAcknowledged, JobNumber, ContractorID)
    SELECT 9, @tsCreated, @UserName, 0, @LogNo, je.contractorid
    FROM [slic3.0].dbo.JobEstimates je WHERE je.legacyreference = CAST(@quotereference AS varchar(50))



SET @LineTotal = (@UnitValue * @Quantity) // IF I CHANGE IT TO ((@UnitValue * 2)) FOR EXMPL



    INSERT INTO fsgmgtservices.dbo.maintlogquotedetails
    (quoteno, details, quantity, rate, amount, [date], slicreference)
    SELECT @QuoteReference, @description, @quantity, @UnitValue, @LineTotal, @tscreated, @JobEstimatesDetailID

    SET @QuoteTotal = (SELECT SUM(mlqd.amount) FROM fsgmgtservices.dbo.maintlogquotedetails mlqd 
    WHERE mlqd.quoteno = @QuoteReference)

    UPDATE fsgmgtservices.dbo.maintlogquotes SET amount = @QuoteTotal WHERE quoteno = @QuoteReference   

    INSERT INTO [fsgmgtservices].[dbo].maintlognotes
    (logno, [date], [user], [note], transferredfromslic)
    SELECT @LogNo, @tsCreated, @UserName, 'Quote ' + CAST(@QuoteReference AS varchar(20)) + ', new lines added by supplier in SLIC By ' + @UserName , 0

END

回答1:


Changing an activated stored procedure does not kill any running instance. Most likely your old code is still running in a loop and will continue to run until it exits the loop or you kill it.



来源:https://stackoverflow.com/questions/23785933/sql-server-altering-service-broker-stored-procedures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!