X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0898652846 for ; Fri, 22 Jul 2005 16:33:19 -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 84900-02 for ; Fri, 22 Jul 2005 19:33:12 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) by svr1.postgresql.org (Postfix) with ESMTP id 8449652840 for ; Fri, 22 Jul 2005 16:33:11 -0300 (ADT) Received: by rproxy.gmail.com with SMTP id i8so317942rne for ; Fri, 22 Jul 2005 12:33:13 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FEB6rTr/5oAb2qadS67fGw2qYVWYuL611h/DNDQSPlNOU4KYSO0onb0QL6ETzRx7GsuvrGAZw9Cn6u2ZQ+w46USSkI86r/5OVmzMOiuiGzpNdVo6FH1Z6fLXciJQXLlLt+pTEVQMNnX3Gd76DcsFICU8aSlx1WMA0zvDlnY5kxI= Received: by 10.38.89.44 with SMTP id m44mr121749rnb; Fri, 22 Jul 2005 12:33:12 -0700 (PDT) Received: by 10.38.97.37 with HTTP; Fri, 22 Jul 2005 12:33:11 -0700 (PDT) Message-ID: Date: Fri, 22 Jul 2005 14:33:11 -0500 From: Jaime Casanova Reply-To: Jaime Casanova To: Bricklen Anderson Subject: Re: Tigger Cc: David Hofmann , pgsql-sql@postgresql.org In-Reply-To: <42E14655.4090106@PresiNET.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <42E14655.4090106@PresiNET.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.217 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200507/201 X-Sequence-Number: 22179 David Hofmann wrote: > > I've look throught the docs and from what I can see the bellow code > > should work, however I keep getting the error: > > > > ERROR: parser: parse error at or near "$" at character 53 > > > > CREATE FUNCTION session_update() RETURNS trigger AS $session_update$ > > BEGIN > > -- Check date exists > > IF NEW.stamp_lastupdate IS NULL THEN > > NEW.stamp_lastupdate :=3D 'now'; > > END IF; > > RETURN NEW; > > END; > > > > $session_update$ LANGUAGE plpgsql; > > > > CREATE TRIGGER session_update BEFORE INSERT OR UPDATE ON sessions FOR > > EACH ROW EXECUTE PROCEDURE session_update(); > > > > > > Any help or suggestions of websites I should read would be appercated. > > > > David >=20 > Which version of postgresql are you using? I don't believe that the "$" q= uoting > was available in older versions than 8 (or late 7?). >=20 the $ quoting is available since 8. This seems bad to me also: > > CREATE FUNCTION session_update() RETURNS trigger AS $session_update$ > > [..function body..] > > $session_update$ LANGUAGE plpgsql; I think it should be: CREATE FUNCTION session_update() RETURNS trigger AS $$ [..function body..] $$ LANGUAGE plpgsql; --=20 Atentamente, Jaime Casanova (DBA: DataBase Aniquilator ;)