MySQL Forums
Forum List  »  Oracle

Multiple auto timestamps
Posted by: Morten Green Hermansen
Date: December 27, 2006 10:07AM

Hello!

I have this table from Oracle:

CREATE TABLE MYTABLE(
USERNAME VARCHAR2(30 CHAR)
VALID_FROM DATE NOT NULL DEFAULT SYSDATE,
VALID_TO DATE NOT NULL DEFAULT SYSDATE);

I depend on some existing code and Hibernate. So I need to be able to do inserts like...

INSERT INTO MYTABLE VALUES('someuser');

... and have the VALID_TO/FROM fields set to the current date unless I give them myself.

I tried:
CREATE TABLE MYTABLE(
`VALID_FROM` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`VALID_TO` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

But got "There can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause"

How is this done in MySQL?

Thanks in advance,
- Morten Green Hermansen, Fanitas

Options: ReplyQuote


Subject
Views
Written By
Posted
Multiple auto timestamps
6594
December 27, 2006 10:07AM
2884
December 27, 2006 11:59AM


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.