[dbo].[ItemCodeVanlineMappingImportValidation]
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