[web] using current_user [mysql]

Started by
1 comment, last by NeoJigglypuff 15 years, 10 months ago
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)
);
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.
Thanks. I just came from using iSQL, which uses "current_user" in a different way. I'll use a procedure then.

This topic is closed to new replies.

Advertisement