What do you mean "instead of running the same query across all lines again and again."?
For each head in rTable I want to count the number of lines. If I want the same type of result I should use the same query, right? Even though the query is the same, the result will be different depending on the head I am running it on.
This is the "same" code I run in another method which sets the AvgApprover field to different values for each row just as intended, even thought ,like in the above code, it runs the "same query".
ttsbegin;
while select forUpdate vTable
{
select count(RecId) from approver
join docLine where docLine.recid == approver.LINEREFRECID
join docTable where docTable.RECID == docLine.DocHeaderRefRecId && vTable.VendAccount == docTable.VendAccount
join vTrans where vTrans.recid == docTable.VENDTRANSID;
vTable.AvgApprovers = approver.RecId;
vTable.update();
}
ttscommit;
Maybe Im missing something completely, but what I thought my code did was to go through the rows in rTable, and for each row it would do the count-query to count the lines of that row. So lets say I have 100 rows in rTable each with varying number of lines. It would run this query 100 times and save those 100 values into the field in those 100 rows.
When I run the query
select count(RecId) from vTrans
group by rTableForCount.RecId
join rTableForCount where rTableForCount.Voucher == vTrans.Voucher
join docTable where docTable.VendTransId == vTrans.RecId
join docLine where docLine.DocHeaderRefRecId == docTable.RecId
join approver where approver.LineRefRecid == docLine.RecId;
in the SQL server database I instantly get the different values for every row. So if the database can do it instantly, why is it not possible in x ? I am really just trying to save the data from that database query into a table.
