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 DA5BAD7016 for ; Mon, 22 Aug 2005 11:30:10 -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 11279-08 for ; Mon, 22 Aug 2005 14:30:07 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id D475ED6FEC for ; Mon, 22 Aug 2005 11:30:05 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7MESkQb013592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Aug 2005 08:28:49 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7MESkac060196; Mon, 22 Aug 2005 08:28:46 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7MESkbs060195; Mon, 22 Aug 2005 08:28:46 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 22 Aug 2005 08:28:46 -0600 From: Michael Fuhr To: neil.saunders@accenture.com Cc: pgsql-sql@postgresql.org Subject: Re: Problem calling stored procedure Message-ID: <20050822142846.GA60111@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/184 X-Sequence-Number: 22412 On Mon, Aug 22, 2005 at 03:17:02PM +0200, neil.saunders@accenture.com wrote: > ERROR: syntax error at or near "$1" at character 70 > QUERY: SELECT * FROM bookings WHERE (start_date, end_date) OVERLAPS (DATE $1 - interval '1 day', DATE $2 + interval '1 day') AND property_id = $3 LIMIT 1 > CONTEXT: PL/pgSQL function "insert_period" line 12 at select into variables > SELECT INTO clashes * FROM bookings WHERE (start_date, end_date) OVERLAPS (DATE new_start_date - interval '1 day', DATE new_end_date + interval '1 day') AND property_id = prop_id LIMIT 1; Why did you write "DATE new_start_date" and "DATE new_end_date"? That's not the correct syntax for casting, and those variables are already of type DATE anyway. > The other thing that concerns me is that the error shows $1 being > used as a DATE argument, I would have thought 'prop_id' (See below) > would have been $1? $N in the error message refers to a statement preparation argument, not to a function argument. For insight into what PL/pgSQL is doing, see the PREPARE documentation: http://www.postgresql.org/docs/8.0/static/sql-prepare.html -- Michael Fuhr