Hi,

I have a problem with updating records in a grouped sql query:

I have to tables one "header"-table and one "line"-table.
As usual (e.g. in Salestable/Salesline) there can be several
records in the line table for one header record.

In both tables I have a Quantity field. Now I want to check,
if the sum of quantities in the tables lines is the same as
in the table header, if not I want to mark the table header,
to indicate the user that there is a problem.

I have the following query:

while select sum(Qty),headerid from linetable
                group by headerid
        join forupdate headertable
            where linetable.headerid==headertable.headerid &&
                linetable.Qty!=headertable.Qty
{
       headertable.Checked=checkfailed;
       headertable.update();
}

The query works so far as it correctly identifies all
records with differing quantities. However the update
fails because Axapta constructs the query in the
SQL-server such that the headertable is included in the
group by and therefore does not return a complete
record but something grouped.

Any ideas how I can restructure the query to do what I want?

Stefan Osterburg


Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to