Find - Exist methods

Find

/// <summary>
/// Finds a <c>TableName</c> record.
/// </summary>
/// <param name = "_recordId">Record Id</param>
/// <param name = "_forUpdate">A <c>Boolean</c> value that indicates whether to read the record for update; optional.</param>
/// <returns>The <c>TableName</c> record if found; otherwise, <c>null</c>.</returns>
public static TableName find(RecordId _recordId, boolean _forUpdate = false)
{
    TableName tableName;

    if(_recordId)
    {
        if(_forUpdate)
        {
            TableName.selectForUpdate(_forupdate);
        }

        select firstonly1 tableName
            where tableName.Id == _recordId;
    }

    return TableName;
}

Exist

/// <summary>
/// Indicates whether the specified record in the <c>TableName</c> table exists.
/// </summary>
/// <param name = "_recordId">Record Id</param>
/// <returns>true if the specified record exists; otherwise, false.</returns>
public static boolean exist(RecordId _recordId)
{
    return _recordId && (select firstonly1 RecId from TableName
        where TableName.Id == _recordId).RecId != 0;
}

Advansed exist

/// <summary>
/// Indicates whether the specified record in the <c>TableName</c> table exists.
/// </summary>
/// <param name = "_recordId">Record Id</param>
/// (Optional) The line number associated with the record. 
/// If not provided (or set to <c>naReal()</c>), the method checks only by <c>_recordId</c>.
/// <returns>true if the specified record exists; otherwise, false.</returns>
public static boolean exist(RecordId _recordId, LineNum _lineNum = naReal())
{
    if (!_recordId)
    {
        return false;
    }

    if (_lineNum == naReal())
    {
        return (select firstonly1 RecId from TableName
                    where TableName.Id == _recordId).RecId != 0;
    }

    return (select firstonly1 RecId from TableName
                where TableName.Id == _recordId
                TableName.LineNum == _lineNum).RecId != 0;
}

Tmp table find

/// <summary>
/// Finds a <c>TableName</c> record.
/// </summary>
/// <param name = "_recordId">Record Id</param>
/// <param name = "_buffer"><c>TableName</c> table buffer.</param>
/// <param name = "_forUpdate">A <c>Boolean</c> value that indicates whether to read the record for update; optional.</param>
/// <returns>The <c>TableName</c> record if found; otherwise, <c>null</c>.</returns>
public static TableName find(RecordId _recordId, TableName _buffer, boolean _forUpdate = false)
{
    if(_recordId)
    {
        if(_forUpdate)
        {
            _buffer.selectForUpdate(_forupdate);
        }

        select firstonly1 _buffer
            where _buffer.Id == _recordId;
    }

    return _buffer;
}

Tmp table exist

/// <summary>
/// Indicates whether the specified record in the <c>TableName</c> table exists.
/// </summary>
/// <param name = "_recordId">Record Id</param>
/// <param name = "_buffer"><c>TableName</c> table buffer.</param>
/// <returns>true if the specified record exists; otherwise, false.</returns> public static boolean exist(RecordId _recordId, TmpTable _buffer) { boolean ret; if (_initRecId) { select firstonly1 RecId from _buffer where _buffer.Id == _recordId; ret = (_buffer.RecId != 0); } return ret; }