Autoincrement field does not get data from server after post

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Zsolt Csillag
Posts: 30
Joined: Sun 28 May 2006 16:09

Autoincrement field does not get data from server after post

Post by Zsolt Csillag » Sun 24 Sep 2006 21:02

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

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 25 Sep 2006 11:24

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.

Zsolt Csillag
Posts: 30
Joined: Sun 28 May 2006 16:09

Post by Zsolt Csillag » Tue 26 Sep 2006 21:20

Hello,

The Cached Updates=false.

Is there any other setting that can cause this error?

Thank you in advance

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 27 Sep 2006 11:19

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

Zsolt Csillag
Posts: 30
Joined: Sun 28 May 2006 16:09

Post by Zsolt Csillag » Wed 27 Sep 2006 19:23

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

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 29 Sep 2006 07:44

MySQL Server does not let MyDAC know if the field is autoincrement if you use DISTINCT keyword in SELECT statement.

Post Reply