timestamp no fractional seconds

Поиск
Список
Период
Сортировка
От Brandon Metcalf
Тема timestamp no fractional seconds
Дата
Msg-id Pine.LNX.4.58L.0906021120310.17533@cedar.geronimoalloys.com
обсуждение исходный текст
Ответы Re: timestamp no fractional seconds  (hubert depesz lubaczewski <depesz@depesz.com>)
Re: timestamp no fractional seconds  (Brandon Metcalf <brandon@geronimoalloys.com>)
Re: timestamp no fractional seconds  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-general
I need to create a table with two columns of type timestamp but I
don't want to store any fractional part of the seconds field.  So,
I created a table with:

  CREATE TABLE timeclock (
      timeclock_id  SERIAL,
      employee_id   INTEGER,
      clockin       TIMESTAMP[0]    NOT NULL,
      clockout      TIMESTAMP[0]    DEFAULT NULL,

      PRIMARY KEY (timeclock_id),

      FOREIGN KEY (employee_id)
          REFERENCES employee
          ON DELETE RESTRICT
          ON UPDATE CASCADE
  );

But now I can no longer insert a timestamp as I normally would:

  gms=# insert into timeclock (employee_id,clockin,clockout) values(3169,now(),null);
  ERROR:  column "clockin" is of type timestamp without time zone[] but expression is of type timestamp with time zone
  LINE 1: insert into timeclock (employee_id,clockin,clockout) values(...
                                             ^
  HINT:  You will need to rewrite or cast the expression.

If I cast it, I get something really strange:

  gms=# insert into timeclock (employee_id,clockin,clockout) values(3169,now()::timestamp,null);
  ERROR:  column "clockin" is of type timestamp without time zone[] but expression is of type timestamp without time
zone
  LINE 1: insert into timeclock (employee_id,clockin,clockout) values(...
                                             ^
  HINT:  You will need to rewrite or cast the expression.

Am I creating the table correctly?  If so, how do I insert or update
rows?

Thanks.


--
Brandon

В списке pgsql-general по дате отправления:

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: loops
Следующее
От: John R Pierce
Дата:
Сообщение: Re: loops