0
votes

This error 'the cursor is open' took me some hours to resolve, so I submit here the explanation in order to propose a solution for people experiencing the same problem.

Problem description : trying to get data from postgreSQL through standard function SQLEXEC raised "Syntax Error", while the same query runs correctly on PGAdmin. Morecover, subsequent queries systematically raised "The cursor is open" (each time being necessary to kill Postgres process AND to reinit the VFP connexion).

Conditions: Postgres 9.3.3, Windows XP SP2, PostgreSQL ODBC Driver(UNICODE) version 9.02.01.00, Visual FoxPro 9 SP1

Solution: SQLExec 3rd parameter should not contain a dot ("."). For example, the command SQLExec(1, 'Select 1', '.F.') raises the problem, when SQLExec(1, 'Select 1', 'F') does not.

In my case '.F.' value was generated programmatically, which made the diagnosis difficult.

1
Are you sure that Postgres 6.3.3? - Roman Tkachuk
There never was a Postgres 6.x that ran on Windows. The first Postgres version to support Windows was 8.0 - a_horse_with_no_name
Sorry, I speak about Postgres 9.9.3. This is now corrected - Luc

1 Answers

1
votes

That is not a VFP error bur programmer's error. The 3rd parameter is a cursor name for the result and as said in the documentation a cursor name cannot have dot. OTOH 'F' is a valid cursor name.

As per the syntax error, very likely you were trying to pass a long sql string literal over 255 characters but can't be sure as we don't see your code. In VFP it is also documented that character literals cannot exceed 255 in length.