Find方法 Exist方法

在ax中新建表时,通常要实现这两个方法,以便于重用。下面贴出Find与Exists方法示例,摘自表InvenBatch

Find方法:

static InventBatch find(InventBatchId _inventBatchId, ItemId _itemId, boolean _forupdate = false)
{
    InventBatch inventBatch;
    ;
    inventBatch.selectForUpdate(_forupdate);

    if (_inventBatchId)
    {
        select firstonly inventBatch
            index hint itemBatchIdx
            where inventBatch.ItemId    == _itemId       &&
                  inventBatch.InventBatchId   == _inventBatchId;

    }

    return inventBatch;
}

Exists方法:

static boolean exist(
    ItemId          itemId,
    InventBatchId   batchId
    )
{
    return (select inventBatch
                index hint itemBatchIdx
                where inventBatch.ItemId        == itemId    &&
                      inventBatch.InventBatchId == batchId).RecId != 0;
}

posted @ 2012-03-02 08:53  perock  阅读(345)  评论(0编辑  收藏  举报