pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PDH.KFI3@t-online.de
To: pgsql-sql@postgresql.org
Subject: function date_part
Date: Tue, 11 Apr 2000 15:07:15 +0200
Message-ID: <00041115394501.03152@boerse> (raw)

Hi,

I need a primary key (int4) in a table which is build from the actual year and a
serial number like 20000001 (year 2000 and the serial number 0001).
If I get the function date_part to build this number like
    select 
       int4(date_part('year', 'now'::datetime) * 10000 + nextval('serial_seq'))
    as primkey; 
it works.
If I use this in a create table like
    create table primtab(
       primkey
            int4 
	primary key
            default 
            int4(date_part('year', 'now'::datetime) * 1000+nextval('serial_seq'))
    ); 
it never works.
	ERROR:  parser: parse error at or near "'"

If I use it in a create function like
    create function primfnc() returns int4
      as 'select .... as primnum'
      language 'sql';
it never works.
	ERROR:  parser: parse error at or near "year"

Is there a mistake in the SQL-QUERY's or isn't it implemented?

Thanks for an answer

Andreas
 -- 
Andreas Stahlhut                                stahlhut@talkline.de
Diplomverwaltungswirt
PD Hannover, ZKD, 3.2 K                         PDH.KFI3@t-online.de
Alter Flughafen 18a                             Tel (0511) 109-5377
30179 Hannover                                  Fax (0511) 109-5330



view thread (2+ messages)  latest in thread

Message-ID: <00041115394501.03152@boerse>
Permalink:  ../00041115394501.03152@boerse/
Also on:    postgresql.org/message-id/00041115394501.03152@boerse

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: PDH.KFI3@t-online.de
  Subject: Re: function date_part
  In-Reply-To: <00041115394501.03152@boerse>
  References: <00041115394501.03152@boerse>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox