Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-01

Zeos Component Join Query

9 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Massimo Fazzolari

Hi,

I have two tables:

- Customers
- Invoices

I got an *sql logic error* trying to execute following query using Zeos Component (ZQuery):

"SELECT Invoices.*, Customers.Name
FROM Invoices
LEFT JOIN Customers
ON Invoices.CustomerID= Customers.ID
* WHERE Customers.Name = 'Tom' "*

excluding the Where clause make the query run without problems.

Thank you
Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100112/c0d0d73e/attachment.html>

Reply by email

JoshyFun
to Massimo Fazzolari

Hello Lazarus-List,

Tuesday, January 12, 2010, 6:07:37 PM, you wrote:

MF> I got an *sql logic error* trying to execute following query using Zeos MF> Component (ZQuery):
MF> "SELECT Invoices.*, Customers.Name
MF> FROM Invoices
MF> LEFT JOIN Customers
MF> ON Invoices.CustomerID= Customers.ID
MF> * WHERE Customers.Name = 'Tom' "*
MF> excluding the Where clause make the query run without problems. From my point of view it is a "SQL logic error", I think it should be: "SELECT Invoices.*, Customers.Name
FROM Customers
RIGHT JOIN Invoices
ON Invoices.CustomerID= Customers.ID
WHERE Customers.Name = 'Tom' "

Note the swapping of Customers and Invoices, the other way the SQL engine will sequentially scan all invoices to join them with customer and perform the "where". Anyway I do not know why ZQuery raises and exception :-? (I'm not using Zeos at all).

Best regards, JoshyFun

Reply by email

Massimo Fazzolari
to JoshyFun

Thank you JoshyFun!

The problem remain. Now i can't apply any filter to Invoices fields! :(

For example this query raise an exception:

"SELECT Invoices.*, Customers.Name
FROM Customers
RIGHT JOIN Invoices
ON Invoices.CustomerID= Customers.ID
* WHERE Invoices.Number > 3"*

2010/1/12 JoshyFun

Show quoted text 37 lines
Hello Lazarus-List, Tuesday, January 12, 2010, 6:07:37 PM, you wrote: MF> I got an *sql logic error* trying to execute following query using Zeos MF> Component (ZQuery): MF> "SELECT Invoices.*, Customers.Name MF> FROM Invoices MF> LEFT JOIN Customers MF> ON Invoices.CustomerID= Customers.ID MF> * WHERE Customers.Name = 'Tom' "* MF> excluding the Where clause make the query run without problems. >From my point of view it is a "SQL logic error", I think it should be: "SELECT Invoices.*, Customers.Name FROM Customers RIGHT JOIN Invoices ON Invoices.CustomerID= Customers.ID WHERE Customers.Name = 'Tom' " Note the swapping of Customers and Invoices, the other way the SQL engine will sequentially scan all invoices to join them with customer and perform the "where". Anyway I do not know why ZQuery raises and exception :-? (I'm not using Zeos at all). -- Best regards, JoshyFun -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100112/93938711/attachment.html>

Reply by email

David W Noon
to Massimo Fazzolari

On Tue, 12 Jan 2010 19:01:48 +0100, Massimo Fazzolari wrote about Re: [Lazarus] Zeos Component Join Query:

Show quoted text 10 lines
The problem remain. Now i can't apply any filter to Invoices fields! :( For example this query raise an exception: "SELECT Invoices.*, Customers.Name FROM Customers RIGHT JOIN Invoices ON Invoices.CustomerID= Customers.ID * WHERE Invoices.Number > 3"*

The join should be an INNER JOIN if you want constraints on columns of both tables..

What has any of this to do with Lazarus?

Regards, Dave [RLU #314465] ======================================================================= (David W Noon) =======================================================================

Reply by email

Leonardo M. Ramé
to Massimo Fazzolari: I have two tables: - Customers - Invoices I got an *sql logic error* trying to execute…

Massimo, please before trying with Lazarus/Zeos, please test your query using an external database administration tool like FlameRobin or IbExpert of you are using Firebird.

99% of the time, the problem isn't Zeos, but the query itself.

Leonardo M. Ram? Griensu S.A. - Medical IT C?rdoba Tel.: 0351-4247979 El mar, 12-01-2010 a las 18:07 +0100, Massimo Fazzolari escribi?: > Hi, > > I have two tables: > > - Customers > - Invoices > > I got an sql logic error trying to execute following query using Zeos > Component (ZQuery): > > "SELECT Invoices.*, Customers.Name > FROM Invoices > LEFT JOIN Customers > ON Invoices.CustomerID= Customers.ID > WHERE Customers.Name = 'Tom' " > > excluding the Where clause make the query run without problems. > > Thank you > Max > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Massimo Fazzolari
to Leonardo M. Ramé

Thank you for reply Leonardo.

I'm using SqLite. I tested the query with sqlite command line tool. The query is correct. The problem is Zeos.

2010/1/12 Leonardo M.

Show quoted text 47 lines
Massimo, please before trying with Lazarus/Zeos, please test your query using an external database administration tool like FlameRobin or IbExpert of you are using Firebird. 99% of the time, the problem isn't Zeos, but the query itself. -- Leonardo M. Ram? Griensu S.A. - Medical IT C?rdoba Tel.: 0351-4247979 El mar, 12-01-2010 a las 18:07 +0100, Massimo Fazzolari escribi?: > Hi, > > I have two tables: > > - Customers > - Invoices > > I got an sql logic error trying to execute following query using Zeos > Component (ZQuery): > > "SELECT Invoices.*, Customers.Name > FROM Invoices > LEFT JOIN Customers > ON Invoices.CustomerID= Customers.ID > WHERE Customers.Name = 'Tom' " > > excluding the Where clause make the query run without problems. > > Thank you > Max > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100113/ac5d9b38/attachment.html>

Reply by email

zeljko
to Massimo Fazzolari
Massimo Fazzolari wrote
Thank you for reply Leonardo. I'm using SqLite. I tested the query with sqlite command line tool. The query is correct. The problem is Zeos.

I'm using ZEOS for years, and it works correct (postgresql). Such query (as mentioned here) work without problems.

zeljko

Reply by email

JoshyFun
to Massimo Fazzolari: Thank you for reply Leonardo. I'm using SqLite. I tested the query with sqlite command…

Hello Lazarus-List,

Wednesday, January 13, 2010, 11:26:19 AM, you wrote:

MF> I'm using SqLite. I tested the query with sqlite command line tool. The MF> query is correct. The problem is Zeos.

I had seen some references to that problem with Zeos and SQLite, but not with other DB engines. So it looks like a Zeos+SQLite bug so it should be reported at http://zeosbugs.firmos.at/

Best regards, JoshyFun

Reply by email

Massimo Fazzolari
to JoshyFun

Ok. Thanks JoshyFun. I will report the bug to http://zeosbugs.firmos.at/

2010/1/13 JoshyFun

Show quoted text 22 lines
Hello Lazarus-List, Wednesday, January 13, 2010, 11:26:19 AM, you wrote: MF> I'm using SqLite. I tested the query with sqlite command line tool. The MF> query is correct. The problem is Zeos. I had seen some references to that problem with Zeos and SQLite, but not with other DB engines. So it looks like a Zeos+SQLite bug so it should be reported at http://zeosbugs.firmos.at/ -- Best regards, JoshyFun -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100113/a7727d40/attachment.html>

Reply by email