< update >
Or you can use Sergey's suggestion :)
< /update >
In what context do you need to globally query to get an invoice total? Do you store the invoice total in the invoice header?
If you don't store the total in the header, you can have a function that queries the total without messing with other cursors. If necessary, you can save the current work area and set it back within the function. Calling this function would probably less efficient than the case where you already have the line items loaded for the current invoice.
procedure getinvoicetotal
lparameters invoiceID
local lnTotal
select invNum, sum(amount) as total ;
from invoiceLines where invNum = invoiceID ;
group by invNum ;
into cursor invoiceLinesTemp
lnTotal = invoiceLinesTemp.total
use in invoiceLinesTemp
return lnTotal
endproc
>I need to be able to total an invoice in progress without losing changes, but I'd also like to be able to total a specified invoice at will. What's the easiest/best way to get the best of both worlds?
Steve Gibson