SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[SFC_spViewPO_Select]
(@trans int = NULL)
as
begin
IF @trans = 1
DECLARE @AutoRR TABLE
(
spPONumber nvarchar (30)
,spItemnmbr nvarchar (20)
,spItemDesc nvarchar (65)
,spUofM nvarchar (20)
,spLocncode nvarchar (20)
,spUnitCost float
,spPurchase float
,spReceive float
,spReceiveTmp float
,spOrd int
,spCancel float
,spVendID nvarchar (20)
)
BEGIN
INSERT INTO @AutoRR
(
spPONumber,
spItemnmbr,
spItemDesc,
spUofM,
spLocncode,
spUnitCost,
spPurchase,
spReceive,
spReceiveTmp,
spOrd,
spVendID
)
SELECT PONUMBER,
ITEMNMBR,
ITEMDESC,
UOFM,
LOCNCODE,
CASE WHEN Adjustedprice=0 then UNITCOST else AdjustedPrice end,
QTYORDER-QTYCANCE,
0,
0,
ord,
VendorID
FROM POP10110
WHERE (VENDORID ='KORGRO01 ') AND
EXISTS(Select * from pop10100 where (Ponumber = POP10110.PoNumber) AND
(POSTSTATUS=1) AND
(POSTATUS < 4) AND
(Revision_Number <> 1))
INSERT INTO @AutoRR
(
spPONumber,
spItemnmbr,
spItemDesc,
spUofM,
spLocncode,
spUnitCost,
spPurchase,
spReceive,
spReceiveTmp,
spOrd,
spVendID
)
SELECT POP10110.PONumber,
POP10110.ITEMNMBR,
POP10110.ITEMDESC,
POP10110.UOFM,
POP10110.LOCNCODE,
CASE WHEN POP10110.Adjustedprice=0 then POP10110.UNITCOST else POP10110.AdjustedPrice end,
0,
SUM(POP10500.QTYSHPPD),
0,
POP10110.Ord,
POP10110.VendorID
FROM POP10110 INNER JOIN
POP10500 ON POP10110.PONUMBER = POP10500.PONUMBER AND POP10110.ORD = POP10500.POLNENUM
WHERE (POP10110.VendorID='KORGRO01 ') AND
EXISTS(Select * from pop10100 where (Ponumber = POP10500.PoNumber) AND
(POSTSTATUS=1) AND
(POSTATUS < 4) AND
(Revision_Number <> 1))
GROUP BY POP10110.ITEMNMBR,
POP10110.ITEMDESC,
POP10110.UOFM,
POP10110.LOCNCODE,
POP10110.UNITCOST,
POP10110.PONumber,
POP10110.Ord,
POP10110.Adjustedprice,
POP10110.VendorID
INSERT INTO @AutoRR
(
spPONumber,
spItemnmbr,
spItemDesc,
spUofM,
spLocncode,
spUnitCost,
spPurchase,
spReceive,
spReceiveTmp,
spOrd,
spVendID
)
SELECT ponumber,
Itemnmbr,
ItemDesc,
UofM,
Locncode,
UnitCost,
0,
0,
Quantity,
ord,
VendorID
FROM POPTEMPRECV
WHERE VendorID='KORGRO01 '
SELECT spPONumber as ponumber,
spItemnmbr as itemnmbr,
spItemDesc as itemdesc,
spUofM as uofm,
spLocncode as locncode,
spUnitCost as UnitCost,
SUM(spPurchase) - (SUM(spReceive) + SUM(spReceiveTmp)) as Balance,
spORd as ORD,
SUM(spPurchase) AS TotalPO,
spVendID
FROM @AutoRR
WHERE spVendID = 'KORGRO01 '
GROUP BY spPONumber,
spItemnmbr,
spItemDesc,
spUofM,
spLocncode,
spUnitCost,
spOrd,
spVendID
HAVING SUM(spPurchase) - (SUM(spReceive) + SUM(spReceiveTmp)) > 0
END
ELSE IF @trans = 2
DECLARE @AutoRRII TABLE
(
spPONumber nvarchar (30)
,spItemnmbr nvarchar (20)
,spItemDesc nvarchar (65)
,spUofM nvarchar (20)
,spLocncode nvarchar (20)
,spUnitCost float
,spPurchase float
,spReceive float
,spReceiveTmp float
,spOrd int
,spCancel float
,spVendID nvarchar (20)
)
BEGIN
-- ANOTHER STORE PROCEDURE WITH DIFFERENT CREATED VIRTUAL TABLE...
END
END
このメソッドを実行しようとしましたが、ストアド プロシージャ仮想テーブルでパラメーターを呼び出した後、C# では機能しません。それらを接続した後、C# コードでこのようになるのではないかと考えていました。
SFC_spViewPO_Select(1, parameter1, parameter2, parameter3.. etc..) 次に、SFC_spViewPO_Select(2, parameter1, parameter2, parameter3.. etc..).. の別の番号は、ストアド プロシージャのパラメータで最初に見つかった番号です。 SQL Server ストアド プロシージャに設定した IF ステートメントを示します。これは、if ステートメント条件内で作成した仮想テーブルのパラメーターをフォローアップします。この可能性はありますか?まだ.. :(助けて!