Retrieving default data values for inserted record
Posted: Thu 21 Oct 2021 21:16
I have MySQL tables with default values specified for some fields. When I connect to these tables with a TMyQuery or TMyTable and insert a new row, those fields show as empty. They only show the default values after I post the inserted record. I want to show the default values for these fields when the record is newly inserted. How can I do this?
I have tried setting the dataset's Options.DefaultValues property to True, which works for some fields but introduces another problem: I have a field, UserName, whose default value is current_user(). If I set DefaultValues to true, that field winds up being populated with the string 'current_user' instead of with the *value* for current_user(). How can I both populate and show the default values for the newly inserted fields, and get the correct value for current_user() (and, for that matter, for any other fields who's default is calculated based on a system variable)?
I have tried setting the dataset's Options.DefaultValues property to True, which works for some fields but introduces another problem: I have a field, UserName, whose default value is current_user(). If I set DefaultValues to true, that field winds up being populated with the string 'current_user' instead of with the *value* for current_user(). How can I both populate and show the default values for the newly inserted fields, and get the correct value for current_user() (and, for that matter, for any other fields who's default is calculated based on a system variable)?