Hi guys,
Can I use "update_recordset" to the same variable (table) which is used in its while loop ? Will that change the records retrieved when the "while..." executed ?
I'm writing a code to similar like this :
RetailTransactionSalesTrans RetailTransactionSalesTrans1, RetailTransactionSalesTrans2
select firstonly RetailTransactionSalesTrans1
where RetailTransactionSalesTrans1.transdate == systemdateget() && RetailTransactionSalesTrans1.CustAccount='TEST-1';
while select transDate, custAccount, ItemId, unit, TaxGroup, TaxItemGroup,
sum(Qty), sum(discAmount), sum(taxAmount), sum(netPrice), sum(NetAmount), sum(NetAmountInclTax), avg(Price)
from RetailTransactionSalesTrans2
group by transDate, custAccount, ItemId, unit, TaxGroup, TaxItemGroup
where RetailTransactionSalesTrans2.transDate == RetailTransactionSalesTrans1.transDate
&& RetailTransactionSalesTrans2.custAccount == RetailTransactionSalesTrans1.custAccount
&& RetailTransactionSalesTrans2.MY_ReceiptType == RetailTransactionType::Sales
&& RetailTransactionSalesTrans2.MY_StatementNumber == ""
&& RetailTransactionSalesTrans2.MY_StatementLineRefRecId == 0
{
.
.
newTableA.insert();
.
.
Update_recorset RetailTransactionSalesTrans2
setting MY_StatementNumber = newTableA.numberSeq,
MY_StatementLineRefRecId = newTableA.recid
where RetailTransactionSalesTrans2.transDate == RetailTransactionSalesTrans1.transDate
&& RetailTransactionSalesTrans2.custAccount == RetailTransactionSalesTrans1.custAccount
&& RetailTransactionSalesTrans2.MY_ReceiptType == RetailTransactionType::Sales
&& RetailTransactionSalesTrans2.MY_HasError == NoYes::No;
}
Can the "update_recorset" somehow makes the records created in "while" statement damaged ? Since I test in SQL, with that criteria will result 2 records, but then when debugging, it will loop forever, on the last record (2nd row item)
The idea is in this While statement, I will need to insert it into my other table (newTableA), and when it is insert successfully, I will need to update the source table with the reference Id number and Refrecid of the new record in newTableA.
How to handle this in simple but correct way ? I mean I can look into some of the existing process (code) but it looks quite complicated (or is it have to be that way), also not sure what I'm looking is the correct part to follow.
Thanks,