sozsoft-platform/configs/seeds/sql/object/Stk_P_TransferNumber.sql
2026-10-19 17:35:08 +03:00

18 lines
684 B
Transact-SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- Numarası olmayan transfer belgesine operasyon türünün numaratöründen (Stk_T_OperationType.SequenceName) numara verir.
CREATE OR ALTER PROCEDURE [dbo].[Stk_P_TransferNumber]
@Id uniqueidentifier
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Seq nvarchar(128), @Tenant uniqueidentifier, @No nvarchar(128);
SELECT @Seq = ot.SequenceName, @Tenant = t.TenantId
FROM Stk_T_Transfer t
INNER JOIN Stk_T_OperationType ot ON ot.Id = t.OperationTypeId
WHERE t.Id = @Id AND t.TransferNo IS NULL;
IF @Seq IS NULL
RETURN;
EXEC Adm_P_SequenceNext @Seq, @Tenant, @No OUTPUT;
UPDATE Stk_T_Transfer SET TransferNo = LEFT(@No, 32) WHERE Id = @Id;
END