Tuesday, November 15, 2011

Get Single Records From Datasource and Update records

Hi Friends,

While development i came across the criteria which recommends me to insert or update the records on the basis of perticular field of table. In this case i used the getFirst and getNext methods of the datasource to fetch single records from the specified datasource.

Here is the code sample.......

~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~

InventTrans     tmpInventTrans;

tmpInventTrans = inventTrans_ds.getFirst(0,false);
while(tmpInventTrans)
{
         if(tmpInventTrans.SheAmortCancel == Noyes::No)
        {
            cancelVoucher=false;
            break;
        }
        tmpInventTrans = inventTrans_ds.getNext();
}

~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~

tmpInventTrans = inventTrans_ds.getFirst(0,false);
while(tmpInventTrans)
{
                select forupdate inventTransUpdate where inventTransUpdate.RecId == tmpInventTrans.RecId;
                inventTransUpdate.SheAmortCancel = NoYes::No;
                inventTransUpdate.update();
                tmpInventTrans = inventTrans_ds.getNext();
}
info("Amortization cancellation aborted");

~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~

No comments:

Post a Comment