I read somewhere, but now I can't find it, that one can set a MySQL VARCHAR column as DEFAULT 'user' and it will record the logged in username when a new record is posted and refreshed. I set up several tables that way and, with those tables, it works: when a new record is inserted, my UserName column comes up with the value 'user' but after it's posted and refreshed, it contains the value of the logged in username.
Since then I've created several new tables and tried to set them up the same way, but this clever little trick doesn't work -- for those new tables only. It still works for the tables I originally created this way, but not for the new tables -- they just keep the value 'user' in that UserName column.
What gives? Am I nuts? Can someone point me to where I originally read about this DEFAULT 'user' setting, and/or suggest to me why it works for some tables and not others? The column definition is the same for all instances: `UserName` VARCHAR(50) NULL DEFAULT 'user'.
I know I can easily set a trigger to supply the value, but now 'the blood is up' and I'm on the hunt. Can't rest till I track this down.
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.