title: Used Cursor inside cursor for update it is showing o rows effected, logic is working when i tried manually
body: <p>stored procedure
  Used Cursor inside cursor for update it is showing 0 rows effected, logic is working when i tried manually, declaring and closing done properly.</p>
  
  <p>any changes do i need to do<br>
  or any alternatives than cursor.    </p>
  
  <pre><code>-- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
  ALTER PROCEDURE [dbo].[POS_Discount_Report]
      @OutletId INT  = NULL,  
      @FromDate DATE = NULL,    
      @ToDate DATE = NULL,
      @DiscountPercent  DECIMAL = NULL  
  AS
  begin           
          SELECT  @CutOffInvoiceAmount = AVG(InvoiceAmount) FROM POS_SalesReceiptMaster WHERE StampDate BETWEEN @FromDate AND @ToDate
  
          DECLARE Receipt_cursor CURSOR FOR
          SELECT Id FROM  POS_SalesReceiptMaster WHERE StampDate BETWEEN @FromDate AND @ToDate AND InvoiceAmount &lt;= @CutOffInvoiceAmount
          OPEN Receipt_cursor
          FETCH NEXT FROM Receipt_cursor
                  INTO @ReceiptId
  
          WHILE @@FETCH_STATUS = 0  
              BEGIN
                  DECLARE Item_cursor CURSOR FOR
                  SELECT Id FROM Updated_SalesReceiptItems WHERE ReceiptId = @ReceiptId
                  OPEN Item_cursor
                  FETCH NEXT FROM Item_cursor
                  INTO @ID
  
  
                  WHILE @@FETCH_STATUS = 0  
                  BEGIN
                      SELECT @Percentage = Percentage, @ItemPrice = Price FROM 
                      Updated_SalesReceiptItems WHERE Id = @ID
                      IF @Percentage = 5
                      BEGIN
                          SELECT @UpdatePercentage = Tax5   FROM   Updated_Master 
                          Where Percentage = @DiscountPercent  
                      END
                      ELSE
                                          BEGIN
                              @UpdatePercentage = 5
                      END
  
  
  
                      UPDATE Updated_SalesReceiptItems
                              SET  ProductId   =   Product.ProductId,
                                   Actualprice =   Product.Actualprice,
                                   Quantity    =   Product.Qty,
                                   ProductName =   Product.ProductName,
                                   unit        =   Product.unit,
                                   CategoryName=   Product.CategoryName,
                                   Percentage=     Product.Percentage,
                                   Amount =        Product.Amount FROM
                              (SELECT TOP 1  PM.ProductId, ProductCode, 
  
                             dbo.fn_Get_ProductPrice_By_Outlet(ProductId,@OutletId) 
                                       AS                                                            
                                         Actualprice, 
                                  (CASE WHEN ( dbo.fn_Get_ProductPrice_By_Outlet(@OutletId, ProductId) != 0)
                                      THEN (@ItemPrice  / dbo.fn_Get_ProductPrice_By_Outlet(@OutletId, ProductId)) 
                                      ELSE 0
                                  END)  AS  Qty,
                                  ProductName, Unit, CategoryName, @UpdatePercentage AS Percentage,
                                  dbo.fn_Get_ProductPrice_By_Outlet(@OutletId, ProductId) * (@UpdatePercentage/100) AS TaxAmount
                              FROM dbo.Products_Master PM
                                  INNER JOIN ProductCategory_Master  CM ON  PM.CategoryId = CM.CategoryId
                                  INNER JOIN tax_master  TM ON  PM.TaxId = TM.Id
                               WHERE (@ItemPrice) % nullif(dbo.fn_Get_ProductPrice_By_Outlet(@OutletId, ProductId),0) = 0
                                  AND Percentage = @UpdatePercentage) Product
                      WHERE Id = @ID
                     end
  
  
  
                  FETCH NEXT FROM Item_cursor
                  INTO @ID
                   END
                  CLOSE Item_cursor;
                  DEALLOCATE Item_cursor;
  
  
                  FETCH NEXT FROM Receipt_cursor
                  INTO @ReceiptId
                  END
          CLOSE Receipt_cursor;
          DEALLOCATE Receipt_cursor;
  
  END
  </code></pre>