1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- -- ================================================
- -- Template generated from Template Explorer using:
- -- Create Procedure (New Menu).SQL
- --
- -- Use the Specify Values for Template Parameters
- -- command (Ctrl-Shift-M) to fill in the parameter
- -- values below.
- --
- -- This block of comments will not be included in
- -- the definition of the procedure.
- -- ================================================
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: ²Ü¼Î½Ü
- -- Create date: 2022/8/11
- -- Description: »ñÈ¡·Ö°ü×ÜÊý
- -- =============================================
- IF (EXISTS (SELECT * FROM SYS.OBJECTS WHERE NAME = 'SP_Cust_PDA_GetPackageComplete'))
- DROP PROC SP_Cust_PDA_GetPackageComplete
- GO
- CREATE PROCEDURE SP_Cust_PDA_GetPackageComplete
- -- Add the parameters for the stored procedure here
- @BarCodes AS NVARCHAR(MAX),
- @OrgCode AS NVARCHAR(50)
- AS
- BEGIN
- -- SET NOCOUNT ON added to prevent extra result sets from
- -- interfering with SELECT statements.
- SET NOCOUNT ON;
- -- Insert statements for procedure here
- DECLARE @SQL NVARCHAR(MAX)
- DECLARE @OrgID BIGINT
- SELECT @OrgID = ID FROM Base_Organization WHERE Code = @OrgCode
- IF OBJECT_ID('tempdb..#TempBarCodeTable') IS NOT NULL
- BEGIN
- DROP TABLE #TempBarCodeTable
- END
- CREATE TABLE #TempBarCodeTable (
- BarCode NVARCHAR(500)
- )
- SET @SQL = 'INSERT INTO #TempBarCodeTable SELECT ''' + REPLACE (@BarCodes,',',''' AS BarCode UNION SELECT ''') + ''''
- EXEC(@SQL)
- SELECT DISTINCT
- CASE WHEN (SUBSTRING(Code, 1, 1) = 'C' AND LEN(Code) = 16) THEN SUBSTRING(Code, 1, 9) + '_' + SUBSTRING(Code, 12, 5) ELSE SUBSTRING(Code, 1, LEN(Code) - 5) END AS PackageCode,
- Segment78
- FROM BC_BarCode
- WHERE Code IN (SELECT BarCode FROM #TempBarCodeTable)AND ISNULL(Segment78, 1) <> 1
- END
- GO
- -- EXEC SP_Cust_PDA_GetPackageComplete @BarCodes = 'C220829020100005,C220825020200001,11019999-00012-110-PO1102208300002-10-00001,11019999-00012-110-PO1102208300002-10-00002,11019999-00012-110-PO1102208300002-10-00003,11019999-00012-110-PO1102208300002-10-00004,11019999-00012-110-PO1102208300002-10-00005,M2120201-00030-110-PO1102208300002-20-00001', @OrgCode = '110'
|