我创建了一个存储过程,它按状态、船名和到期日过滤许可证申请记录。该代码已运行用于过滤状态和船舶名称,但EXPIRY DATE
.
该函数应使用 ajax 日历根据文本框上的输入过滤到期日期。
我认为我过滤有效期的条件有问题。
有什么建议么 ?
USE [PhilfishPhilcatch]
GO
/****** Object: StoredProcedure [dbo].[rectesting] Script Date: 11/07/2013 08:53:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[rectesting]
@VesselName Varchar (30) = NULL,
@Status Varchar (10) = NULL,
@DateReleased date = NULL,
@ExpiryDate date = NULL,
@DateIssued date = NULL,
@Cfvgl_Upload varchar = NULL
AS
BEGIN
IF (@Status = 1)
begin
SELECT a.v_id, a.ship_name, b.status, b.cfvgl_validity_start , b.cfvgl_validity_end, b.cfvgl_path, b.cfvgl_date_released
FROM vessel_details as a INNER JOIN
cfvgl as b ON a.v_id = b.v_id
WHERE
a.ship_name LIKE ISNULL(@VesselName+'%', a.ship_name) AND
(b.status = 4 OR b.status = 7)
end
IF (@Status <> NULL OR @Status <> '')
begin
SELECT a.v_id, a.ship_name, b.status, b.cfvgl_validity_start , b.cfvgl_validity_end, b.cfvgl_path, b.cfvgl_date_released
FROM vessel_details as a INNER JOIN
cfvgl as b ON a.v_id = b.v_id
WHERE
a.ship_name LIKE ISNULL(@VesselName+'%', a.ship_name) AND
b.status = @Status
end
IF (@ExpiryDate <> NULL OR @ExpiryDate <> '')
begin
SELECT a.v_id, a.ship_name, b.status, b.cfvgl_validity_start , b.cfvgl_validity_end, b.cfvgl_path, b.cfvgl_date_released
FROM vessel_details as a INNER JOIN
cfvgl as b ON a.v_id = b.v_id
WHERE
b.cfvgl_validity_end = ISNULL (@ExpiryDate, b.cfvgl_validity_end)
end
END