Received: from mailout01.sul.t-online.de (mailout01.sul.t-online.de [194.25.134.80]) by hub.org (8.9.3/8.9.3) with ESMTP id JAA37851 for ; Tue, 11 Apr 2000 09:41:22 -0400 (EDT) (envelope-from PDH.KFI3@t-online.de) Received: from fwd03.sul.t-online.de by mailout01.sul.t-online.de with smtp id 12f0uM-0005Rg-06; Tue, 11 Apr 2000 15:40:46 +0200 Received: from boerse.kfi3.de (051114252-0006@[193.159.140.73]) by fwd03.sul.t-online.de with esmtp id 12f0uD-0YMpyyC; Tue, 11 Apr 2000 15:40:37 +0200 Received: from localhost (localhost [[UNIX: localhost]]) by boerse.kfi3.de (8.9.3/8.9.3/SuSE Linux 8.9.3-0.1) id PAA03375 for pgsql-sql@postgresql.org; Tue, 11 Apr 2000 15:39:50 +0200 From: PDH.KFI3@t-online.de (Andreas Stahlhut) To: pgsql-sql@postgresql.org Subject: function date_part Date: Tue, 11 Apr 2000 15:07:15 +0200 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain MIME-Version: 1.0 Message-Id: <00041115394501.03152@boerse> Content-Transfer-Encoding: 8bit X-Sender: 051114252-0006@t-dialin.net X-Archive-Number: 200004/105 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