Advertisement Jump to content
Sign in to follow this  

[web] using current_user [mysql]

This topic is 3855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to set the current user as a default value for a table column? Something kind of like this:
create table CATEGORY (
     CATEGORY_ID          tinyint                        not null auto_increment,
     CATEGORY_NAME        char(100)                      null,
     ADDED_ON             timestamp                      null,
     ADDED_BY             char(20)                       null,
     LAST_EDITED_ON       timestamp                      not null default current_timestamp on update current_timestamp,
     LAST_EDITED_BY       char(20)                       not null default current_user,
     constraint PK_CATEGORY primary key (CATEGORY_ID)

Share this post

Link to post
Share on other sites
You can't set a function as a default value, the exception being current_timestamp, but you can simulate what you want with a stored procedure. Just remember current_user() returns the user specified in the db connection string, which in a web application probably isn't the same as the logic user.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!