Page 1 of 1

Doesn't refresh autoinc field in a joined query

Posted: Sun 23 Jan 2011 10:00
by starhu
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

Posted: Mon 24 Jan 2011 21:24
by starhu
Nobody can help me? :(

Posted: Tue 25 Jan 2011 19:51
by swierzbicki
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

Posted: Wed 26 Jan 2011 09:09
by AndreyZ
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.

Posted: Thu 27 Jan 2011 09:08
by starhu
Thank you, I will try it!