Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : Union Query for SalesOrdersLine and InvoiceLine TablesSearch Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC SQL Support Forum

 New Topic 
 
 Post Reply 
[1]  
 Union Query for SalesOrdersLine and InvoiceLine Tables 
 Author   Message 
  Matt 
  
 Group: Members 
 Posts: 25 
 Joined: 2006-04-25 
 Profile
 Posted : 2006-04-25 05:14:55

I am trying to combine a couple of queries via a union query. Each individual part works, but when I try to run both in the union query, I get the following error:

ODBC--CALL FAILED
[ODBC] Expected Lexical Element not found: <keyword> (#11015)

 

My SQL is this:

SELECT [shipdate]
FROM [qrysalesorder]

UNION ALL SELECt [shipdate]
from [qryinvoiceline];

All of my tables and queries work, so I don't know why I would get an error with just the Union Query.

I'll also give you my SQL for my queries...

QRYSALESORDER:

SELECT tblSalesOrderLine.ShipDate, tblSalesOrderLine.CustomerRefFullName, tblSalesOrderLine.ShipAddressCity, tblSalesOrderLine.PONumber, tblSalesOrderLine.SalesOrderLineItemRefFullName, tblSalesOrderLine.SalesOrderLineQuantity, tblSalesOrderLine.SalesOrderLineDesc, tblSalesOrderLine.TemplateRefFullName, tblSalesOrderLine.IsFullyInvoiced, tblSalesOrderLine.IsManuallyClosed
FROM tblSalesOrderLine
WHERE (((tblSalesOrderLine.CustomerRefFullName)<>"LDI") AND ((tblSalesOrderLine.SalesOrderLineItemRefFullName) Is Not Null) AND ((tblSalesOrderLine.TemplateRefFullName) Like "PP Work Sales Order") AND ((tblSalesOrderLine.IsFullyInvoiced)=No) AND ((tblSalesOrderLine.IsManuallyClosed)=No));

And for QRYINVOICELINE:

SELECT tblInvoiceLine.ShipDate, tblInvoiceLine.CustomerRefFullName, tblInvoiceLine.ShipAddressCity, tblInvoiceLine.PONumber, tblInvoiceLine.InvoiceLineItemRefFullName, tblInvoiceLine.InvoiceLineQuantity, tblInvoiceLine.InvoiceLineDesc, tblInvoiceLine.TemplateRefFullName
FROM tblInvoiceLine
GROUP BY tblInvoiceLine.ShipDate, tblInvoiceLine.CustomerRefFullName, tblInvoiceLine.ShipAddressCity, tblInvoiceLine.PONumber, tblInvoiceLine.InvoiceLineItemRefFullName, tblInvoiceLine.InvoiceLineQuantity, tblInvoiceLine.InvoiceLineDesc, tblInvoiceLine.TemplateRefFullName
HAVING (((tblInvoiceLine.ShipDate)>#3/1/2006#) AND ((tblInvoiceLine.CustomerRefFullName)<>"LDI") AND ((tblInvoiceLine.InvoiceLineItemRefFullName)<>"ship" And (tblInvoiceLine.InvoiceLineItemRefFullName)<>"rush") AND ((tblInvoiceLine.TemplateRefFullName) Like "Delivery Receipt" Or (tblInvoiceLine.TemplateRefFullName) Like "PP Work Order"));

Again, both of my front end queries work fine, so there's something wrong with the Union Query and QODBC.

Thanks!

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-04-25 10:54:25

Sorry, the use of UNION element will result with a: "Expected Lexical Element not found" error as the UNION element is not implemented in QODBC yet. You will need to pull the results of both queries into a temporary file and work with the results from there.

UNION is on the wish list .....

 

  Top 
  Matt 
  
 Group: Members 
 Posts: 25 
 Joined: 2006-04-25 
 Profile
 Posted : 2006-04-27 02:49:11
For anyone else struggling with the same problem, I was able to get around this by making my original queries make-table queries and running them with macros, then running the union query off of those tables which avoided the lexical error... 

  Top 
  smedesr 
  
 Group: Members 
 Posts: 1 
 Joined: 2007-10-05 
 Profile
 Posted : 2007-10-05 01:38:06
We have v7, what is the syntax for using UNION between 2 select statements? Can you please provide an example? We have read-only so cannot work around this issue by make-table queries. 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2007-10-05 06:51:14

Sorry, QODBC v8.00.00.234 still doesn't except the following SQL syntax:

SELECT Name FROM Customer
Union Select Name from Vendor

or

SELECT Name FROM Customer
Union All Select Name from Vendor

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2008-10-06 15:52:09
Union is now supported using QODBC v9, see: Release 9.0.0.249 Fixes  

  Top 
  tchung 
  
 Group: Members 
 Posts: 1 
 Joined: 2009-01-08 
 Profile
 Posted : 2009-01-08 17:13:19
Can I confirm that UNION with 2 selects that use GROUP BY causes an error "[QODBC] Unable to do GROUP BY". The query in question is:

SELECT sl.TxnDate, sl.CustomerRefFullName, sl.RefNumber, sl.InvoiceLineItemRefFullName, SUM(sl.InvoiceLineQuantity)
FROM InvoiceLine sl WHERE sl.InvoiceLineQuantity IS NOT NULL GROUP BY sl.TxnDate, sl.CustomerRefFullName, sl.RefNumber, sl.InvoiceLineItemRefFullName

UNION

SELECT cl.TxnDate, cl.CustomerRefFullName, cl.RefNumber, cl.CreditMemoLineItemRefFullName, SUM(-cl.CreditMemoLineQuantity)
FROM CreditMemoLine cl WHERE cl.CreditMemoLineQuantity IS NOT NULL GROUP BY cl.TxnDate, cl.CustomerRefFullName, cl.RefNumber, cl.CreditMemoLineItemRefFullName 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2009-01-09 09:21:24
Correct you can't use GROUP BY within a UNION. 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to