Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

how to have two while loop

$
0
0

there is only one 

@@FETCH_STATUS
OPEN Buy_Record_Cursor;
OPEN Sell_Record_Cursor;
FETCH NEXT FROM Buy_Record_Cursor;
FETCH NEXT FROM Sell_Record_Cursor;
WHILE @@FETCH_STATUS = 0
	BEGIN
	WHILE @@FETCH_STATUS = 0
	   BEGIN
		  FETCH NEXT FROM Sell_Record_Cursor;
	   END;
	   FETCH NEXT FROM Buy_Record_Cursor;
	END;
CLOSE Sell_Record_Cursor;
CLOSE Buy_Record_Cursor;
DEALLOCATE Sell_Record_Cursor;
DEALLOCATE Buy_Record_Cursor;

translating following c# code

foreach (OutstandingLots b in BuyRecord)
                {
                    foreach (OutstandingLots s in SellRecord)
                    {
                        if (b.culsum > s.culsum && s.IsRead == false)
                        {

                            OutstandingLots temp = new OutstandingLots();

                            temp.TradeDate = b.TradeDate;
                            temp.SettleDate = b.SettleDate;
                            temp.TranID = b.TranID;
                            temp.NominalPrice = b.NominalPrice;
                            temp.TranPrice = b.TranPrice;
                            temp.AccruedInterest = b.AccruedInterest;

                            if (firstgreater == false)
                            {
                                temp.Quantity = b.culsum - s.culsum;
                                previous_quantity = b.Quantity;
                                cumsum = cumsum + temp.Quantity;
                                firstgreater = true;
                            }
                            else
                            {
                                temp.Quantity = b.Quantity;
                                cumsum = cumsum + temp.Quantity;
                            }
                            AlreadyReadTranNum = s.TranID;
                            temp.culsum = cumsum;
                            accounts.Add(temp);
                        }
                        else if (b.culsum == s.culsum)
                        {
                            previous_quantity = 0;
                            AlreadyReadTranNum = s.TranID;
                        }
                        else
                        {
                            previous_quantity = b.Quantity;
                            AlreadyReadTranNum = 0;
                        }
                    }
                    if (AlreadyReadTranNum != 0)
                        SellRecord = SetRead(SellRecord, AlreadyReadTranNum);
                }
                Session["outstandinglots"] = accounts;
            }


未敏俊


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>