USP_AUCTIONITEM_ADDTOAUCTION

Executes the "Auction Item Add To Auction Record Operation" record operation.

Parameters

Parameter Parameter Type Mode Description
@ID nvarchar(73) IN Input parameter indicating the ID of the record being updated.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the update.

Definition

Copy


                    CREATE procedure dbo.USP_AUCTIONITEM_ADDTOAUCTION
                    (
                        @ID nvarchar(73),
                        @CHANGEAGENTID uniqueidentifier
                    )
                    as begin

                        declare @ITEMID uniqueidentifier = null;
                        declare @AUCTIONID uniqueidentifier = null;

                        select @ITEMID = cast(substring(@ID, 0, 37) as uniqueidentifier)
                        select @AUCTIONID = cast(substring(@ID, 38, 36) as uniqueidentifier)

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

                        declare @CURRENTDATE datetime
                        set @CURRENTDATE = getdate()


                        begin try
                            if not exists
                                        (
                                            select EVENT.BASECURRENCYID 
                                            from dbo.EVENT 
                                            inner join dbo.AUCTIONITEM on AUCTIONITEM.TRANSACTIONCURRENCYID = EVENT.BASECURRENCYID
                                            where EVENT.ID = @AUCTIONID and AUCTIONITEM.ID = @ITEMID
                                        )
                                raiserror('BBERR_AUCTIONITEM_EVENT_BASECURRENCY', 13, 1);

                            update dbo.AUCTIONITEM
                            set 
                                EVENTAUCTIONID = @AUCTIONID,
                                CHANGEDBYID = @CHANGEAGENTID,
                                DATECHANGED = @CURRENTDATE
                            where ID = @ITEMID
                        end try
                        begin catch
                            exec dbo.USP_RAISE_ERROR
                            return 1;
                        end catch

                        return 0;

                    end