Stored Procedures [dbo].[ItemCodeVanlineMappingImportValidation]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)Direction
@inVanlineGroupExternalCodevarchar(10)10
@inItemCodeint4
@outErrorMessagevarchar(256)256Out
Permissions
TypeActionOwning Principal
GrantExecuteMssExec
SQL Script
/*
* Does validations on the VanlineGroupExternalCode and ItemCode.  This is called prior to
* calling the ItemCodeVanlineMappingImportAction.
* Admin uses this stored proc just before importing ItemCodeVanLineMappings from a file.
*/

CREATE PROCEDURE [dbo].[ItemCodeVanlineMappingImportValidation]
    @inVanlineGroupExternalCode varchar(10),
    @inItemCode int,
    @outErrorMessage varchar(256) output
as
set nocount on

set @outErrorMessage = null
declare @theErrorCodeID int = 0
declare @VANLINE_GROUP_EXTERNAL_CODE_CANNOT_BE_FOUND int = 920
declare @ITEM_CODE_CANNOT_BE_FOUND int = 921

if( @inVanlineGroupExternalCode is not null )
begin
    if( not exists ( select top 1 1 from VanLineGroup where VanlineExternalCode = @inVanlineGroupExternalCode ) )
    begin
        set @theErrorCodeID = @VANLINE_GROUP_EXTERNAL_CODE_CANNOT_BE_FOUND
    end
end

if( @theErrorCodeID = 0 )
begin
    if( not exists ( select top 1 1 from ItemCode where ItemCode = @inItemCode ) )
    begin
        set @theErrorCodeID = @ITEM_CODE_CANNOT_BE_FOUND
    end
end

if( @theErrorCodeID > 0 )
begin
    set @outErrorMessage = ( select [Description] from ErrorCode where ECPriKey = @theErrorCodeID )
end
GO
GRANT EXECUTE ON  [dbo].[ItemCodeVanlineMappingImportValidation] TO [MssExec]
GO
Uses
Used By