How to: Update Data

You can use the while select statement to modify data. For more information, see while select Statements.

All select statements use a table variable. This variable must be declared before a select statement can be executed. For more information, see Tables as Data Types.

In the following example, the doDelete Table Method table method is called in the while select loop to delete records in the LedgerJournalTrans table. A record is deleted when the condition specified by the where clause is met.

The ttsBegin and ttsCommit keywords are used to help ensure the integrity of the data transaction. For more information, see Transaction Integrity.

static void deleteTransFromVoucher(LedgerJournalId _journalNum,Voucher _voucher)
    LedgerJournalTrans ledgerJournalTrans;
    LedgerJournalTable ledgerJournalTable = LedgerJournalTable::find(_journalNum);
    Counter            counter;
    while select forUpdate ledgerJournalTrans
        index hint NumVoucherIdx
            where ledgerJournalTrans.journalNum == _journalNum 
               && ledgerJournalTrans.voucher == _voucher
    if (counter && ledgerJournalTable.journalType != LedgerJournalType::Periodic)
    NumberSeq::release(ledgerJournalTable.voucherSeries, _voucher);

Community Additions