Jump to content
  • Advertisement
Sign in to follow this  
NeoJigglypuff

[web] using current_user [mysql]

This topic is 3761 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
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!