USE [MES_DS_MCD]
GO
/****** Object: StoredProcedure [SSRS].[MataAnodes_p] Script Date: 2014/8/5 10:39:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [SSRS].[MataAnodes_p]
-- Add the parameters for the stored procedure here
@MaterialUA varchar(30) = NULL,
@Operation varchar(30) = NULL,
@PN varchar(50) = NULL,
@DateFrom varchar(50) = NULL,
@DateTo varchar(50) = NULL,
@OracleOrgCode varchar(30) = NULL,
@LogicalPlant varchar(30) = NULL
AS
SET NOCOUNT ON;
Declare @mat varchar(20)
Declare @date varchar(20)
--if @MaterialUA='Material'
-- set @mat= ' AND ( part_type Like '''+@PN +'''' +' or partnum Like '''+@PN +'''' +' ) '
-- else
-- if @MaterialUA='UA'
-- set @mat= ' AND uano Like '''+@PN +'%'''
-- if @Operation='Prensas'
-- set @date= ' where CAST(OMASTERDATE AS DATE) between ''' + @DateFrom + ''' And '''+ @DateTo + ' '' '
--else
-- if @Operation='Sin'
-- set @date= ' where CAST(fin_date AS DATE) between ''' + @DateFrom + ''' And '''+ @DateTo + ' '' '
Declare @sql varchar(max)='SELECT * from APPS.MATA_ANODES '
--Set @sql = @sql + @date
if @Operation='Prensas'
Set @sql = @sql + ' where CAST(OMASTERDATE AS DATE) between ''' + @DateFrom + ''' And '''+ @DateTo + ' '' '
else
if @Operation='Sin'
Set @sql = @sql + ' where CAST(fin_date AS DATE) between ''' + @DateFrom + ''' And '''+ @DateTo + ' '' '
if @MaterialUA='Material'
set @sql = @sql + ' AND ( part_type Like '''+@PN +'%''' +' or partnum Like '''+@PN +'%''' +' ) '
else
if @MaterialUA='UA'
set @sql = @sql + ' AND uano Like '''+@PN +'%'''
--Set @sql = @sql + @mat
exec (@sql)
return