` Retrieving autonumbered MySQL record (Bjarne Havnen - Aditech As) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

SQL Related Articles: Retrieving autonumbered MySQL record
2005-11-28 -- Bjarne Havnen - Aditech As
 
Newsgroups: softvelocity.clarion.databasedrivers > Anybody with experience of using auto_increment > keys with MySQL? > The problem is that Clarion auto_number returns > the next value by reading the biggest value from > the table and MySQL gives the value from an internal > field-value when physically adding the record. And > these are not necessary the same. > > I need to know the auto_incremented value because > the same procedure updates two other related tables. > > I can handle this by hand-coding (re-reading the added > record) but if anybody has figured out how to handle the > auto_increment -values, please give information. Sample code from my filemanager used with mysql Add the record, retrive the last_insert_id() and then fetch the record to retrive the entire recordbuffer. I have derived the PrimeAutoInc method to support this. Other choose to do similar things in a form, others override the Savebutton to first add the record and then retrieve it before enabling child inserts. I prefer my way in all cases where I work with files where I will be adding records manually Add(Self.File) If Errorcode() Message(FileError()) ReturnVAlue = Level:Fatal Exit End Self.File{Prop:Sql}='Select Last_Insert_Id()' Next(Self.File) Self.Fetch(AutoKey)


Today is April 24, 2024, 8:34 am
This article has been viewed 35112 times.
Google search has resulted in 10 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: