USP_EVENTCONFLICT_ADDRESOURCE

Adds a resource to an event conflict.

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier INOUT
@CHANGEAGENTID uniqueidentifier IN
@EVENTCONFLICTID uniqueidentifier IN
@RESOURCEID uniqueidentifier IN
@QUANTITYNEEDED int IN

Definition

Copy


      CREATE procedure dbo.USP_EVENTCONFLICT_ADDRESOURCE
      (
                @ID uniqueidentifier = null output,
                @CHANGEAGENTID uniqueidentifier = null,
                @EVENTCONFLICTID uniqueidentifier,
                @RESOURCEID uniqueidentifier,
                @QUANTITYNEEDED int = 0
      )
      as

                set nocount on;

                if @ID is null
                    set @ID = newid()

                if @CHANGEAGENTID is null  
                    exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output

                declare @CURRENTDATE datetime
                set @CURRENTDATE = getdate()

                begin try
                    declare @PERTICKETQUANTITY int
                    select @PERTICKETQUANTITY = PERTICKETQUANTITY
                    from dbo.RESOURCE
                    where ID = @RESOURCEID 

                    -- handle inserting the data

                    insert into dbo.EVENTRESOURCE
                        (ID, EVENTCONFLICTID, RESOURCEID, QUANTITYNEEDED, PERTICKETQUANTITY, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
                    values
                        (@ID, @EVENTCONFLICTID, @RESOURCEID, @QUANTITYNEEDED, @PERTICKETQUANTITY, @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE)

                end try

                begin catch
                    exec dbo.USP_RAISE_ERROR
                    return 1
                end catch

                return 0