WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.



Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Pervasive SQL Syntax Error


I'm having trouble with my script and would appreciate help on trouble-shooting it. Here is part of my script.

MyTableName="Order Master"
retcode = qExecDirect(hstmt, "SELECT ORDNUM, PRTNUM FROM %MyTableName%")

My script uses ODBC functions to help me access the Order Master file for specific data. It keeps crashing with the error message "37000 [Pervasive][ODBC Client Interface][....]Syntax Error:SELECT ORDNUM, PRTNUM FROM Order<<>> Master"

I used the sample script that came with the ODBC extender. I know it works because it successfully displays the messages that appear before the script that is giving me the above error message.


My guess is the problem is due to the ‘table name’ having a space in it. The format of "statement" will depend on the data source and driver. You will need to handle for the space in the ‘table name’, in the SQL string that you pass to qExecDirect.

Other SQL Strings to try:

;retcode = qExecDirect(hstmt, "SELECT SHOPORDERNUM, PARTID FROM [%MyTableName%]")
;retcode = qExecDirect(hstmt, "SELECT SHOPORDERNUM, PARTID FROM '%MyTableName%'")
;retcode = qExecDirect(hstmt, 'SELECT SHOPORDERNUM, PARTID FROM "%MyTableName%"')

User Reply:

The last of line of your example is the correct one.
retcode = qExecDirect(hstmt, 'SELECT SHOPORDERNUM, PARTID FROM "%MyTableName%"')
Table names with spaces in them must be enclosed in double quotes within the query string. Literals, on the other hand, need to be in single quotes (apostrophes).

Article ID:   W16342
File Created: 2017:07:28:13:58:32
Last Updated: 2005:02:18:12:19:55