MySQL Forums
Forum List  »  Oracle

Re: DEFAULT NOW() AND DEFAULT USER ...
Posted by: Roland Bouman
Date: February 03, 2006 08:26AM

I think you should do it like this:

D_FEC_CRE TIMESTAMP DEFAULT CURRENT_TIMESTAMP

see: http://dev.mysql.com/doc/refman/5.0/en/timestamp-4-1.html

This is the only case where a non-constant expression can be used a a default value for a column, so you cannot use this for the V_USU_CRE column.

If you are migrating to MySQL 5, you can solve that with a BEFORE INSERT trigger:

delimiter //

create trigger bir_RGMD_GESTION
before insert on RGMD_GESTION
for each row
begin
if new.V_USU_CRE is null then
set V_USU_CRE := SESSION_USER();
end if;
end;
//

although it is not entirely equivalent: this does not distinguish between the case where the V_USU_CRE is not present in the insert statement and the ce where it is present and explicitly set to NULL. (I believe that in Oracle the latter case would in fact insert a NULL in the column as it is explicitly requested.)

You should check out Beat's comments on the right function to use for the current user bit:

http://www.futhark.ch/mysql/116.html
and
http://www.futhark.ch/mysql/123.html

Options: ReplyQuote


Subject
Views
Written By
Posted
20697
February 02, 2006 04:30PM
Re: DEFAULT NOW() AND DEFAULT USER ...
9954
February 03, 2006 08:26AM


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.