Jan 4, 2012

How to write a find() in a table


 
static  MyTable find(PrimarykeyEDT  _PrimaryKey)
{
MyTable  MyTable  ;
;
select firstonly   MyTable  ;

return (  MyTable);
}

=============  (OR) =============


public static  MyTable  find(EDTDocumentId _DocumentId, boolean _forupdate = false)
{
     MyTable   MyTable  = null;
    ;

     MyTable .selectForUpdate(_forupdate);

    if(_DocumentId)
    {
        select firstonly MyTable
        where  MyTable DocumentId == _DocumentId;
    }

    return  MyTable ;
}

      Example of find()
=================


static COL_ShipmentTerms find(COL_ShipmentTermId     ShipmentTermId,
                       boolean          _forUpdate = false,
                       ConcurrencyModel _concurrencyModel = ConcurrencyModel::Auto)
{
    COL_ShipmentTerms  shipmentTerms;
    ;

    if (ShipmentTermId)
    {
        if (_forUpdate)
        {
            shipmentTerms.selectForUpdate (_forUpdate);
            if (_concurrencyModel != ConcurrencyModel::Auto)
                shipmentTerms.concurrencyModel(_concurrencyModel);
        }
        shipmentTerms.selectLocked    (_forUpdate);

        select firstonly shipmentTerms
            index hint ShipmentTermIdx
            where shipmentTerms.ShipmentTermId == ShipmentTermId;
    }

    return shipmentTerms;
}









No comments: