Hi,
I'm just curious if this will work, or if there is a better way to do this. When I run just the cursor alone and hard code the StockistID, my cursor works. When I put this cursor into a stored procedure and pass a param to this cursor, it is not recognized Does anyone know how I can pass a paramater from a stored procedure to a cursor? Thx in advance. Code is below and does NOT work:
Create Procedure spMobileStockistSalesForSelectedMonthAndYear
(
@ParamStockistID varchar(25)
)
As
GO
--declare all variables
Declare @ReceiptNumber varchar(11)
--here we define the cursor
DECLARE authors_cursor CURSOR FOR
SELECT ReceiptNumber, Sum(tblOrders.Quantity) AS SumOfQuantity
FROM tblStockist INNER JOIN tblOrders ON tblStockist.StockistID = tblOrders.StockistID
GROUP BY tblOrders.ReceiptNumber
HAVING (((tblStockist.StockistID)=@ParamStockistID) AND ((tblStockist.Code)<>'CA76969980'))
ORDER BY tblOrders.ReceiptNumber
I'm just curious if this will work, or if there is a better way to do this. When I run just the cursor alone and hard code the StockistID, my cursor works. When I put this cursor into a stored procedure and pass a param to this cursor, it is not recognized Does anyone know how I can pass a paramater from a stored procedure to a cursor? Thx in advance. Code is below and does NOT work:
Create Procedure spMobileStockistSalesForSelectedMonthAndYear
(
@ParamStockistID varchar(25)
)
As
GO
--declare all variables
Declare @ReceiptNumber varchar(11)
--here we define the cursor
DECLARE authors_cursor CURSOR FOR
SELECT ReceiptNumber, Sum(tblOrders.Quantity) AS SumOfQuantity
FROM tblStockist INNER JOIN tblOrders ON tblStockist.StockistID = tblOrders.StockistID
GROUP BY tblOrders.ReceiptNumber
HAVING (((tblStockist.StockistID)=@ParamStockistID) AND ((tblStockist.Code)<>'CA76969980'))
ORDER BY tblOrders.ReceiptNumber