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
|
|
Using WHERE in Pass-Through Queries |
Author |
Message |
Matt |
|
Group | : Members |
Posts | : 25 |
Joined | : 2006-04-25 |
|
Profile |
|
Posted : 2006-05-26 03:54:05 |
I'm wondering how to write the SQL for multiple WHERE functions for ODBC. I'm sure it is a simple problem, but I've written it in several different ways but haven't had any success. My SQL is as follows:
select ShipDate, CustomerRefFullName,ShipAddressCity,PONumber,SalesOrderLineItemRefFullName, SalesOrderLineQuantity,SalesOrderLineDesc,ShipMethodRefFullName,TemplateRefFullName, IsFullyInvoiced,IsManuallyClosed,RefNumber from salesorderLine nosync WHERE Txndate >= {d '2006-05-01'} AND isfullyinvoiced=yes
It gives me the error message: Column not found
Thanks! |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2006-05-26 09:13:14 |
There's no problem with your WHERE clause, you just haven't used the right format for IsFullyInvoiced:
select ShipDate, CustomerRefFullName,ShipAddressCity,PONumber,SalesOrderLineItemRefFullName, SalesOrderLineQuantity,SalesOrderLineDesc,ShipMethodRefFullName,TemplateRefFullName, IsFullyInvoiced, IsManuallyClosed,RefNumber from salesorderLine nosync WHERE Txndate >= {d '2006-05-01'} AND isfullyinvoiced=TRUE
Valid values for IsFullyInvoiced are 1, 0, TRUE, FALSE as can been seen using:
sp_columns SalesOrderLine
|
|
|
|
Matt |
|
Group | : Members |
Posts | : 25 |
Joined | : 2006-04-25 |
|
Profile |
|
Posted : 2006-05-27 00:29:46 |
Ok, works great. Now, I am trying to add some more WHERE clauses but again am struggling with the format for TemplateRefFullName. I ran the sp salesorderline in vbdemo but can't make heads or tails of what it's talking about for TemplateRefFullName. Not sure what %s means.
select ShipDate, CustomerRefFullName,ShipAddressCity,PONumber,SalesOrderLineItemRefFullName,SalesOrderLineQuantity, SalesOrderLineDesc,ShipMethodRefFullName,TemplateRefFullName,IsFullyInvoiced,IsManuallyClosed,RefNumber from salesorderLine nosync WHERE Txndate >= {d '2006-05-01'} AND isfullyinvoiced=false AND ismanuallyclosed=false AND TemplateRefFullName=PP Work Sales Order
Thanks! |
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2006-05-27 09:18:27 |
%s means string of undefined length.
String literals in your queries need to be in single quotes as in:
select ShipDate, CustomerRefFullName,ShipAddressCity,PONumber,SalesOrderLineItemRefFullName,SalesOrderLineQuantity, SalesOrderLineDesc,ShipMethodRefFullName,TemplateRefFullName,IsFullyInvoiced,IsManuallyClosed,RefNumber from salesorderLine nosync WHERE Txndate >= {d '2006-05-01'} AND isfullyinvoiced=false AND ismanuallyclosed=false AND TemplateRefFullName='PP Work Sales Order' |
|
|
|
Matt |
|
Group | : Members |
Posts | : 25 |
Joined | : 2006-04-25 |
|
Profile |
|
Posted : 2006-05-31 07:21:28 |
Ok, another follow-up. I want to limit the templates to 3 or 4 in my pass-through query. I've tried it several different ways. With the SQL I tried below, I think it would work, but it wants to re-optimize.
Select Customerreffullname, ShipAddressCity, shipdate, invoicelineservicedate, InvoiceLineItemRefFullName, TemplateRefFullName from invoiceLine unoptimized WHERE Txndate >= {d '2006-02-01'} AND InvoiceLineItemRefFullName='WW:Bin' AND TemplateRefFullName='Pickup Request' OR TemplateRefFullName='Bin Invoice'
Thank you!
|
|
|
|
Tom |
|
Group | : Administrator |
Posts | : 5510 |
Joined | : 2006-02-17 |
|
Profile |
|
Posted : 2006-05-31 09:52:17 |
You have used the UNOPTIMIZED tag, so it will reload the query directly from QuickBooks, try:
Select Customerreffullname, ShipAddressCity, shipdate, invoicelineservicedate, InvoiceLineItemRefFullName, TemplateRefFullName from invoiceLine NOSYNC WHERE Txndate >= {d '2006-02-01'} AND InvoiceLineItemRefFullName='WW:Bin' AND (TemplateRefFullName='Pickup Request' OR TemplateRefFullName='Bin Invoice')
You should also have a bracket around the two TemplateRefFullNames. |
|
|
|
Matt |
|
Group | : Members |
Posts | : 25 |
Joined | : 2006-04-25 |
|
Profile |
|
Posted : 2006-06-01 03:56:53 |
Actually, I need to keep the unoptimized tag so I have the most up-to-date data. But, for whatever reason, the parentheses did the trick as far as eliminating the slowness. So, everything is working great and the pass-through queries are running even faster since this WHERE SQL eliminates alot of the needless data. |
|
|
|
|