X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9D9DCD8555 for ; Tue, 6 Sep 2005 11:00:39 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 66727-06 for ; Tue, 6 Sep 2005 14:00:27 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 78250D8511 for ; Tue, 6 Sep 2005 11:00:28 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 8AED43549C; Tue, 6 Sep 2005 07:00:33 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 894D935463; Tue, 6 Sep 2005 07:00:33 -0700 (PDT) Date: Tue, 6 Sep 2005 07:00:33 -0700 (PDT) From: Stephan Szabo To: Harald Fuchs Cc: pgsql-sql@postgresql.org Subject: Re: ERROR: syntax error at or near "select" at character 9 In-Reply-To: <871x427euh.fsf@srv.protecting.net> Message-ID: <20050906065924.Y35524@megazone.bigpanda.com> References: <4317FE8C.7020803@axis.hu> <20050905213103.F5782@megazone.bigpanda.com> <871x427euh.fsf@srv.protecting.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200509/59 X-Sequence-Number: 22606 On Tue, 6 Sep 2005, Harald Fuchs wrote: > In article <20050905213103.F5782@megazone.bigpanda.com>, > Stephan Szabo writes: > > > On Fri, 2 Sep 2005, [ISO-8859-2] Graf L=E1szl=F3 wrote: > > >> > >> CREATE FUNCTION test_verif() RETURNS trigger AS $test_verif$ > >> BEGIN > >> NEW.id :=3D select nextval('test_azon_seq'); > > > I think you want to remove select here, you're already effectively doin= g a > > select of the right hand side in the assignment. > > >> NEW.nev :=3D nev; > > I think you want to remove this line entirely. What nev were you > > expecting on the right hand side? If it's the new one, well, NEW.new i= s > > already that. > > L=E1szl=F3 could also remove the entire trigger and use something like > > > CREATE TABLE test ( > id SERIAL NOT NULL, > nev VARCHAR(25), > datum TIMESTAMP NOT NULL DEFAULT current_timestamp, > PRIMARY KEY (id) > ); That's slightly different though. The trigger forces the value whether or not a value was assigned in the insert, the defaults only apply if the column does not have a value given to it.