Hello.
I’ve not done a great deal of A2K development, but I have done quite a bit under A97. I’ve got an A2K database converted from A97 and a number of the queries are running really slowly now. I’ve pinpointed the problem to be a change in the way A2K handles functions called from queries. Under A97, if you called a function from a query and didn’t pass it any field values from the query it was called once only, under A2K it seems to call the function once per record.
I’ve looked through Help and also MSDN and the only concrete thing I’ve found was a knowledge base article titled “ACC2000: Number of Times a Custom Function Runs in a Query” (Q210554). Unfortunately this confirms what I was expecting (that the function should only be called once per query execution) not what seems to be happening (once per record). I’ve tried the example in the article in case something really odd was happening in my real application, but it exhibits the same behaviour.
To save anyone looking, this is the query and the function from the MSDN article. It uses the Northwind sample DB.
SELECT Employees.LastName, ShouldIncrement() AS RecordNumber FROM Employees;
Global RecordNum
Function ShouldIncrement()
RecordNum = RecordNum + 1
ShouldIncrement = RecordNum
End Function
The example shows the query returning 1 in the RecordNumber field for each record where in fact it returns a different value for each record. Is this a bug? A new feature? Is there some setting I can turn off? Any other simple workaround?
Thanks in advance,
Simon.