Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread SELECT with INNER JOIN adds new records
Sun, Jan 22 2012 12:38 PMPermanent Link

Janusz Cyran

It seems that SELECT with INNER JOIN adds new records to result set. I see it in a grid connected with appropriate DataSource. Every next time the user runs SELECT the old values still are visible and new ones are added. The simple SELECT without JOIN works differently and in a grid each time only single values appears.
Sun, Jan 22 2012 1:17 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Janusz,

JOIN and INNER JOIN should produce the exact same result set, and none of them should add its result set to an existing  result set of a previously executed query, no matter if it is a JOIN or any other kind of SELECT.
If that is what you are seeing, that's not an expected or normal behavior. Can we have some more details on what you are doing and how, as well as what EDB version you are using, please?

--
Fernando Dias
[Team Elevate]
Sun, Jan 22 2012 1:51 PMPermanent Link

Janusz Cyran

The version is ElevateDB 2.05 Build 11.

Here is the relevant code:

// Wrong behaviour:
 with qZwrot do
 begin
   Close;
   SQL.Text := 'SELECT s.Symbol, s.Nazwa, s.Ilosc, p.Ilosc AS IloscPZ, s.Barkod';
   SQL.Text := SQL.Text + 'FROM StanyRob s ';
   SQL.Text := SQL.Text + 'INNER JOIN PZARob p ON (s.Barkod = p.Barkod) ';
   SQL.Text := SQL.Text + ' WHERE s.Ilosc > 0 ORDER BY s.Nazwa';
   Open;
 end;

// Proper behaviour:
 with qZleBarkody do
 begin
   Close;
   SQL.Text := 'SELECT Symbol, Ilosc, Barkod FROM PZARob p WHERE CzyCyfry(p.Barkod) < 0';
   Open;
 end;
Sun, Jan 22 2012 2:53 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Janusz ,

I don't see anything unusual happening with similar queries here, but I don't have 2.05.11 installed anymore, I'm testing with 2.06.2.

Do you also see it happening in EDB Manager or only in your application?

--
Fernando Dias
[Team Elevate]
Sun, Jan 22 2012 4:42 PMPermanent Link

Janusz Cyran

Only in my application. Additionaly, when I first run 2x, 3x, etc SELECT in the application and see doubled records in the grid, then run the same SELECT in Manager, the result set is doubled, tripled etc. The consecutive execution in Manager doesn't add new records, but the last result from application is visible.
Sun, Jan 22 2012 5:51 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Janusz ,

Have you tried a REPAIR on those 2 tables?
If that doesn't fix it, can you post the structure of the tables and indexes so that I can test it here, please?

--
Fernando Dias
[Team Elevate]
Mon, Jan 23 2012 3:36 PMPermanent Link

Janusz Cyran

Fernando,

I've got it! It was a side effect of my other error, sorry. Anyway thank you for your great support, as always Smile

Janusz
Image