Customer account for LedgerJournalTrans

i want custmer account and i have only LedgerJournalTrans table, for that i write this query, is that correct or not…

LedgerJournalTrans ledgerJournalTrans;

DimensionAttributeValueCombination dimensionAttributeValueCombination;

CustTable custTable;

select * from custTable where custTable.AccountNum ==(select DisplayValue from dimensionAttributeValueCombination

where dimensionAttributeValueCombination.RecId == ledgerJournalTrans.LedgerDimension);

return custTable.AccountNum;

I would do this:

if (trans.AccountType == LedgerJournalACType::Cust)
{
    custAccount = DimensionStorage::ledgerDimension2AccountNum(
	                                trans.LedgerDimension);
}