Doesn't refresh autoinc field in a joined query

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
starhu
Posts: 34
Joined: Thu 13 Aug 2009 12:13

Doesn't refresh autoinc field in a joined query

Post by starhu » Sun 23 Jan 2011 10:00

Hello,

I have aTMyQuery. The refreshOption.roAfterInsert = True.

If I use the query with one table only it refreshes the autoncrement field, but if i use a similar like below, it will not.

select distinct a.* from a left join b on (a.a_autoinc=b.b_a_autoinc);

In this case I can get the autoinc only if I refresh the whole query and that takes a lot of time. And I must get the autoinc after post because I need to insert rows in the detail table.

How can I do this?

Thank you in advance

starhu
Posts: 34
Joined: Thu 13 Aug 2009 12:13

Post by starhu » Mon 24 Jan 2011 21:24

Nobody can help me? :(

swierzbicki
Posts: 451
Joined: Wed 19 Jan 2005 09:59

Post by swierzbicki » Tue 25 Jan 2011 19:51

Hello,

I don't have delphi under my hand... I will write what goes out of my head :
- You should set the fullrefresh option to true.
- You should set KeyFields property and set UpdatingTable property
- Double click on your TMyQuery Component and go to the generate SQL Tab. : you will be able there to generate custom SQL statements.

This should works now. Give it a try.

BR

SW

AndreyZ

Post by AndreyZ » Wed 26 Jan 2011 09:09

Hello,

If you are using the DISTINCT keyword in the SELECT statement, MySQL Server doesn't inform MyDAC that the field is autoincrement. Please try excluding the DISTINCT keyword from your SQL statement and check if the problem persists.

starhu
Posts: 34
Joined: Thu 13 Aug 2009 12:13

Post by starhu » Thu 27 Jan 2011 09:08

Thank you, I will try it!

Post Reply