チェックボックスについてサポートが必要です。これが私のコードです:
CREATE PROCEDURE stad_list
@inp_location_code numeric (3,0) = -1
@inp_item_code_bgn numeric (5,0) = -1
@inp_item_code_end numeric (5,0) = -1
@inp_shipped numeric (2,0) = 0, --checkbox, if it is checked then returns the items in table which were shipped (value in table is 1)
@inp_check numeric (2,0) = 0, --checkbox, if it is checked then returns data which is still in process of checking for availability in warehouse (value in table is 0)
@inp_not_ship numeric(2,0) = 0 --checkbox, if it is checked then returns data which had not been shipped during some problems (valuein table is 2)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @SELECT as varchar (3000) = ''
DECLARE @WHERE as varchar (1000) = ''
IF (@inp_location_code != -1)
SET @WHERE = @WHERE + ' WHERE [dbo].item.location =' + CONVERT(varchar,@inp_location_code)
IF (@inp_item_code_bgn != -1)
SET @WHERE = @WHERE + ' AND [dbo].item.code>=' + CONVERT(varchar, @inp_item_code_bgn)
IF (@inp_item_code_end != -1)
SET @WHERE = @WHERE + ' AND [dbo].item.code<=' + CONVERT(varchar, @inp_item_code_end)
IF (@inp_shipped = 1)
SET @WHERE = @WHERE + ' AND [dbo].item.ship = 1'
IF (@inp_check = 1)
SET @WHERE = @WHERE + ' AND [dbo].item.ship = 0'
IF (@inp_not_ship = 1)
SET @WHERE = @WHERE + ' AND [dbo].item.ship = 2'
SET @SELECT = @SELECT + '
SELECT
[dbo].item.name as ''NAME'',
[dbo].item.location as ''LOCATION'',
[dbo].item.code as ''CODE'',
[dbo].item.ship as ''STATUS''
FROM [dbo].item '
+ @WHERE
EXEC (@SELECT)
RETURN @@ROWCOUNT
END
チェックボックスを1つだけチェックしている場合は正常に機能しますが、2つチェックボックスをオンにしているとデータを取得できません。では、2つのチェックボックスをオンにしたい場合はどうすればよいですか?助言がありますか?
これが私のテーブルです
Id Item_code Item_name Item_location Item_ship
1 14789 Juice Tokyo 0
2 14785 Boots Tokyo 2
3 98744 Hat Osaka 0
4 36987 Socks Kyoto 1
そして、3つのチェックボックスがあります
発送済み
チェック中
出荷されていません
出荷を確認すると、出力は次のようになります。
Id Item_code Item_name Item_location Item_ship
4 36987 Socks Kyoto 1
しかし、私は元のためにそうしたいです。Shipped and Checkingをチェックすると、出力は次のようになります。
Id Item_code Item_name Item_location Item_ship
1 14789 Juice Tokyo 0
3 98744 Hat Osaka 0
4 36987 Socks Kyoto 1