Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alter PROCEDURE [dbo].[KC_GENERATE_SSCC] @CONTAINER_ID NVARCHAR(124) OUTPUT
- AS
- BEGIN
- begin tran
- declare @len int = (
- select user_def6 from next_number
- where next_num_key = N'LicensePlateUniqueId'
- );
- declare @prefix nvarchar(25) = (
- select top 1 user3value from generic_config_detail
- where record_type = N'KC_PLANT' and user2value = 'Y'
- );
- declare @SSCC nvarchar(124);
- -- -d
- declare @lpn nvarchar(25) = (
- select next_num from next_number
- where next_num_key = N'LicensePlateUniqueId'
- );
- update next_number
- set next_num = iif(
- next_num !> user_def8
- ,next_num + 1
- ,cast(user_def7 as int)
- )
- where next_num_key = N'LicensePlateUniqueId';
- set @SSCC = @prefix + replicate('0', @len - LEN(@lpn) - LEN(@prefix) - 1) + @lpn
- set @SSCC = '00' + @SSCC + dbo.KC_BARCODE_CHKDIGIT(@SSCC);
- set @CONTAINER_ID = @SSCC
- commit tran
- END
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement