“Function Sequence Error” in VFP Remote Views

This was a first for me. An application that had been working fine suddenly started throwing a “Function Sequence Error” when retrieving data from a remote view. That error message was a little misleading, as I didn’t have any functions in my view that could even be out of sequence!
Googling around didn’t lead to a direct answer, although plenty of folks have had similar issues with various clients besides Visual FoxPro. (I’m amazed that anyone would take the suggestion of “Reinstall SQL Server” seriously!) There were enough clues in those answers that eventually led me to how to fix this however.
Essentially what’s going on here is that you’re trying to use records in a remote view before Visual FoxPro has completed fetching all the records down from SQL Server. This most often happens when you’ve configured your remote view to only grab a limited # of records at a time. That’s the “function sequence” that’s out of whack.
The easiest thing to do to fix this is to simply tell Visual FoxPro to retrieve all your records in the remote view configuration (Modify View / Query / Advanced Options / check “All” next to “Number of Records to Fetch at a Time”. If that’s not an option you could also trap for this error and keep retrying until all the records are downloaded, but that seems suboptimal.
Hope this helps!






2 responses to ““Function Sequence Error” in VFP Remote Views”

  1. Andy Avatar

    Isn’t there some way to get both side to agree on the max # of selected records, like a read() request – you know you’re done (or in trouble) when the request returns less the full number or zero?

  2. Steve Avatar

    Eric, that’s interesting – and I think we might have seen a different version of that error or a related error in production.

    When this application was put into production the record sets were very small. Over time, the remote view settings started causing us trouble on really big tables.

    I’m afraid I haven’t had to deal with this in a long time and I don’t remember all the details. I’ve been looking at the remote views using ViewEditor and the Fetch Size is 100, Max Records is -1 and “Fetch As Needed” is unchecked for all the views I’ve looked at – except the one that likely first returned the largest record set. For that one, Fetch Size is set to -1.

    My guess is ViewEditor’s “Fetch Size” is the same as “Number of Records to Fetch at a time”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.