db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satheesh Bandaram <sathe...@Sourcery.Org>
Subject Re: insert timestamp upon insert?
Date Thu, 01 Dec 2005 18:25:14 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
You can also define a default on the timestamp column... Derby allows
references to special registers in default clause.<br>
<br>
Like: creation_date timestamp not null <b>default current timestamp</b>,<br>
<br>
Satheesh<br>
<br>
Mike Matrigali wrote:
<blockquote cite="mid438F3563.3090509@sbcglobal.net" type="cite">you
probably can use an insert trigger to get the desired result.
  <br>
  <br>
Michael McCutcheon wrote:
  <br>
  <blockquote type="cite">Suppose I have a table like this:
    <br>
    <br>
CREATE TABLE discussion_thread
    <br>
(
    <br>
&nbsp;&nbsp; discussion_thread_id&nbsp;&nbsp; INTEGER&nbsp;&nbsp;&nbsp;&nbsp;
NOT NULL GENERATED ALWAYS AS
IDENTITY (START WITH 1, INCREMENT BY 1),
    <br>
&nbsp;&nbsp; title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
VARCHAR(50) NOT NULL,
    <br>
&nbsp;&nbsp; creation_date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
TIMESTAMP&nbsp;&nbsp; NOT NULL,
    <br>
&nbsp;&nbsp; creator_user_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
VARCHAR(32) NOT NULL
    <br>
);
    <br>
    <br>
Is there a way to have derby automatically populate the creation_date
column with the current date/time upon insert?
    <br>
    <br>
Mike
    <br>
    <br>
    <br>
    <br>
  </blockquote>
  <br>
  <br>
  <br>
</blockquote>
</body>
</html>


Mime
View raw message