very often we do update and insert in tables using select and while select,In ax first thing to know is the diffrence between select and while select.
Say we are going to update a existing record:
rule No1: select that particular record
rule no2: use ttsbegin and commit
rule no3:assign the value and do "update" or "doupdate";
*******************
static void Job31(Args _args)
{
LedgerJournalTable LedgerJournalTable;
;
select forUpdate LedgerJournalTable where LedgerJournalTable.JournalName =="ttt";
ttsbegin;
LedgerJournalTable.JournalNum = '1478.45';
LedgerJournalTable.AssetTransferType_LT = LtAssetTransferType::TransferJour;
LedgerJournalTable.update();
ttscommit;
}
*************************************
say we are inserting a new value in a table
follow this rule
1.intialise the table.
2.assign the vaulue to the table's field
3.write the insert or doinsert method.
static void Job31(Args _args)
{
LedgerJournalTable LedgerJournalTable;
;
LedgerJournalTable.initValue();
LedgerJournalTable.JournalName = "ttt";
LedgerJournalTable.JournalNum = '4578.124';
LedgerJournalTable.AssetTransferType_LT = LtAssetTransferType::TransferJour;
LedgerJournalTable.insert();
if(LedgerJournalTable.validateWrite())
{
LedgerJournalTable.insert();
}
}
Say we are going to update a existing record:
rule No1: select that particular record
rule no2: use ttsbegin and commit
rule no3:assign the value and do "update" or "doupdate";
*******************
static void Job31(Args _args)
{
LedgerJournalTable LedgerJournalTable;
;
select forUpdate LedgerJournalTable where LedgerJournalTable.JournalName =="ttt";
ttsbegin;
LedgerJournalTable.JournalNum = '1478.45';
LedgerJournalTable.AssetTransferType_LT = LtAssetTransferType::TransferJour;
LedgerJournalTable.update();
ttscommit;
}
*************************************
say we are inserting a new value in a table
follow this rule
1.intialise the table.
2.assign the vaulue to the table's field
3.write the insert or doinsert method.
static void Job31(Args _args)
{
LedgerJournalTable LedgerJournalTable;
;
LedgerJournalTable.initValue();
LedgerJournalTable.JournalName = "ttt";
LedgerJournalTable.JournalNum = '4578.124';
LedgerJournalTable.AssetTransferType_LT = LtAssetTransferType::TransferJour;
LedgerJournalTable.insert();
if(LedgerJournalTable.validateWrite())
{
LedgerJournalTable.insert();
}
}
great
ReplyDelete