[QODBC-Desktop] Troubleshooting: Expected lexical element not found
Posted by Rajendra Dewani (QODBC Support) on 31 October 2012 11:51 AM

Troubleshooting: Expected lexical element not found

Problem Description 

When trying to execute a query statement, I get the error message " Expected lexical element not found."

Solutions

It seems to be the issue in the SQL Statement. Please check all the field names and table names. Usually, this could be a typo error in the field name in your SQL Statement. To know more about the fields and data layout, please Click Here 

Another Possible Problem & Solution:

Problem Description:

When I issue SQL statement:

SELECT Desc FROM Charge 

I get "Expected lexical element not found: = <identifier>."

However, if I issue

Select * from Charge

Then, I get a full output with one of the columns named "Desc."

Why can't I query for the column by name?

I have tried this through the QODBC Support Wizard and a C# program. 

Solution: 

I want to inform you that Desc may be a reserved word in SQL; you are getting this error. I kindly request you to please put quotes around "Desc." Please use the below query, which does not issue an error:
 
SELECT "Desc" FROM Charge 

 

Problem Description:

I am trying to clear a date column for the JobStartDate and I am getting an error. Any help would be great, I could not find a help article on this.

I am using .net if that matters.


Dim jobStartDate As Date? = Nothing

Dim cmd As New OdbcCommand($"
UPDATE customer
SET jobStartDate = {jobStartDate}
WHERE ListID = '{listID}' ",
con)

cmd.ExecuteNonQuery()


ERROR [42000] [QODBC] [sql syntax error] Expected lexical element not found: = CASE


Dim jobStartDate As Date = Nothing

Dim cmd As New OdbcCommand($"
UPDATE customer
SET jobStartDate = {jobStartDate}
WHERE ListID = '{listID}' ",
con)

cmd.ExecuteNonQuery()

Message = "ERROR [42000] [QODBC] Unexpected extra token: :00:00"

SELECT Desc FROM Charge 

I get "Expected lexical element not found: = <identifier>."

However, if I issue

Select * from Charge

Then, I get a full output with one of the columns named "Desc."

Why can't I query for the column by name?

I have tried this through the QODBC Support Wizard and a C# program. 

Solution: 

Please ensure the SQL statement generated by your application is as per the following example. Please ensure the date format is correct.
 
UPDATE customer
SET jobStartDate = {d'2022-11-18'}
WHERE ListID = 'YourListIDValue' 

 

 

(5 vote(s))
Helpful
Not helpful

Comments (2)
Ricky Bowman
12 February 2018 05:31 PM
I get the same error message when running a query in Microsoft Query against the customer table in quickbooks. I modified the query to only select one column and still get the same error. My query is: select listid as id from customer.
Jack
13 February 2018 01:36 PM
Hi Ricky,

Please use below query & check again:

select listid as “id” from customer

If you are still the facing issue, Please raise a support ticket to the QODBC Technical Support department from below mentioned link & provide requested information:
http://support.flexquarters.com/esupport/index.php?/Tickets/Submit

We may need the following information, Please attach below listed files when replying to the ticket.
1) Screenshot of QODBC Setup Screen -- > About
2) Screenshot of the issue you’re facing.
Share Entire Log Files as an attachment in text format from
3) QODBC Setup Screen -- > Messages -- > Review QODBC Messages
4) QODBC Setup Screen -- > Messages -- > Review SDK Messages
Refer: How to take screenshot: www.qodbc.com/links/screenshot.htm

Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please complete the captcha below (we use this to prevent automated submissions).