UFN_AMPROIMPORT_GETAUCTIONIDFORBATCHROW
Returns the auction event ID for a row in an AuctionMaestro Pro import batch.
Return
| Return Type | 
|---|
| uniqueidentifier | 
Parameters
| Parameter | Parameter Type | Mode | Description | 
|---|---|---|---|
| @BATCHAMPROIMPORTID | uniqueidentifier | IN | 
Definition
 Copy 
                                    
            CREATE function dbo.UFN_AMPROIMPORT_GETAUCTIONIDFORBATCHROW
            (
                @BATCHAMPROIMPORTID uniqueidentifier
            )
            returns uniqueidentifier
            as
            begin
                --The AMPROIMPORTDATA row is on the original batch; it does not get copied when an exception batch 
                --is created. So chase down the originating batch for any exception batches.
                declare @R uniqueidentifier = null;
                declare @BATCHID uniqueidentifier = null;
                declare @REALBATCHID uniqueidentifier = null; 
                select top 1 @BATCHID = BATCHID from dbo.BATCHAMPROIMPORT where ID = @BATCHAMPROIMPORTID;
                set @REALBATCHID = @BATCHID;
                declare @ISEXCEPTIONBATCH bit = 0;
                select 
                    @ISEXCEPTIONBATCH = 1
                from dbo.BATCH where BATCH.ID = @BATCHID and ORIGINATINGBATCHID is not null;
                while @ISEXCEPTIONBATCH = 1
                begin
                    set @ISEXCEPTIONBATCH = 0;
                    set @REALBATCHID = @BATCHID;
                    select 
                        @ISEXCEPTIONBATCH = 1,
                        @BATCHID = BATCH.ORIGINATINGBATCHID
                    from dbo.BATCH where BATCH.ID = @BATCHID and ORIGINATINGBATCHID is not null;
                end
                select top 1 
                    @R = BATCHAMPRODATA.EVENTAUCTIONID
                from dbo.BATCHAMPRODATA
                where BATCHAMPRODATA.ID = @REALBATCHID;
                return @R;
            end