Master Detail Tables
Posted: Thu 11 Jul 2013 03:38
I am switching from SQL to MYSQL and could use some help retrieving the value of the auto increment index of the Master Table. I'm sure my way of doing so even when using SQL may have been wrong but it worked so I assumed what I was doing was OK. Anyway, what I had been doing was to Post, then do a
LastID := DM.Markers.Dataset.FieldByName('Marker_ID').AsInteger;
and use LastID in my Foreign Key field in the Detail Table Record. That has always worked perfectly.
Now that I'm trying to switch over to MYSQL I get 0 back for LastID when doing so. I know that in MYSQL there is a function LAST_INSERT_ID(); that can be executed but I'm not sure how or where to use that. Can someone point me in the right direction please? Thanks!
LastID := DM.Markers.Dataset.FieldByName('Marker_ID').AsInteger;
and use LastID in my Foreign Key field in the Detail Table Record. That has always worked perfectly.
Now that I'm trying to switch over to MYSQL I get 0 back for LastID when doing so. I know that in MYSQL there is a function LAST_INSERT_ID(); that can be executed but I'm not sure how or where to use that. Can someone point me in the right direction please? Thanks!