Subject Error defining a Firebird view in VFP
Author drjimwalsh1
I'm writing a Visual FoxPro application that accesses a Firebird database. I am getting an error when VFP initially defines the view. The error appears to be coming from the Firebird driver. Here is my code to define the view:

LOCAL lcSQLSortColDirection AS String

CREATE SQL VIEW vNP CONNECTION (sMyDataSource) SHARE ;
AS SELECT PATIENTS.USR_NAME, PATIENTS.USR_FIRSTNAME, ;
PATIENTS.USR_DATEBIRTH, PATIENTS.USR_PatientID, ;
PATIENTS.USR_CITY, PATIENTS.PatientNo AS PatientNo ;
FROM Patients PATIENTS ORDER BY (?lcSQLSortColDirection)

I get the following error when VFP executes this statement

Connectivity error: [ODBC Firebird Driver][Firebird]Dynamic SQL Error
SQL error code = -804
Data type unknown

If I replace ?lcSQLSortColDirection with "USR_NAME" it works fine.

How can I create the view so that the ORDER BY clause is variable?

Thanks,
Jim