Page 1 of 1

Autoincrement field does not get data from server after post

Posted: Sun 24 Sep 2006 21:02
by Zsolt Csillag
Hello,


The main table has an autoinc field. If the user makes a new record,
this field would not get the value generated by the server ONLY if I make a full refresh.
But in this case the customer cannot add bar codes to it (these are child rows and need this field).
In normal use when the customer makes a new record and then adds several bar codes into the child table, after post the keys of these child rows will be null.

To see my problem, click on the link below and have a look at the highlighted field:
http://invitel.hu/csillagzs/autoinc_error.jpg

Thank you very much

Posted: Mon 25 Sep 2006 11:24
by Antaeus
Possible you work in CachedUpdates mode. In this mode updates is applied to the server after calling AppllyUpdates. Auto increment values are returned from the server also after calling AppllyUpdates method.

Posted: Tue 26 Sep 2006 21:20
by Zsolt Csillag
Hello,

The Cached Updates=false.

Is there any other setting that can cause this error?

Thank you in advance

Posted: Wed 27 Sep 2006 11:19
by Antaeus
We could not reproduce the problem.
Please send us (evgeniyD*crlab*com) a complete small sample to demonstrate it, including script to create and fill table.

Also supply us following information
- Exact version of Delphi, C++ Builder or Kylix
- Exact version of MyDAC. You can see it in About sheet of TMyConnection Editor
- Exact version of MySQL server and MySQL client. You can see it in Info sheet of TMyConnection Editor

Posted: Wed 27 Sep 2006 19:23
by Zsolt Csillag
Hello,

At last I found out what causes the problem though I don't know how to
workaround it.
This is not a simple select in the TMyQuery but a joined one with Distinct.
The Distinct causes this problem (if I don't use distinct the autoinc will refresh):

SELECT DISTINCT(Termek_Azonosito), Termek_Letrehozas_Idobelyeg,
Termek_Megnevezes ,
Termek_BeszerzesiAr,
Termek_Csomagolasi_egyseg,
Termek_MinimumKeszlet,
Termek_Megjegyzes,
Termek_AktualisKeszlet,
Termek_TermekCsop_Azon,
Termek_Afa,
Termek_UtolsoLeltarDatuma,
Termek_Vamtarifa,
Termek_EladasiAr1,
Termek_EladasiAr2,
Termek_EladasiAr3,
Termek_UtolsoBeszallitoKod
FROM
uzlet.termek
LEFT JOIN
uzlet.termek_vonalkod ON uzlet.termek.Termek_Azonosito = uzlet.termek_vonalkod.tv_termek_azon


The sql above joins the Product table (termek) with its bar code table (termek_vonalkod).
Because a product can have many bar codes, I have to use Distinct.

The two tables are joined because the customer wants to search both using product names and bar codes.

Have you got any suggestions?

Thank you

Posted: Fri 29 Sep 2006 07:44
by Antaeus
MySQL Server does not let MyDAC know if the field is autoincrement if you use DISTINCT keyword in SELECT statement.