Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 689B29FAA6E; Mon, 18 Jun 2007 11:44:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 45016-01; Mon, 18 Jun 2007 11:43:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mtao05.charter.net (mtao05.charter.net [209.225.8.179]) by postgresql.org (Postfix) with ESMTP id 63BC19FA06D; Mon, 18 Jun 2007 11:43:58 -0300 (ADT) Received: from aa04.charter.net ([10.20.200.156]) by mtao05.charter.net (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070618144356.DDBN10967.mtao05.charter.net@aa04.charter.net>; Mon, 18 Jun 2007 10:43:56 -0400 Received: from [10.0.1.2] (really [66.188.164.45]) by aa04.charter.net with ESMTP id <20070618144356.JFBY3826.aa04.charter.net@[10.0.1.2]>; Mon, 18 Jun 2007 10:43:56 -0400 In-Reply-To: <467696D7.2090703@terra.com.br> References: <467696D7.2090703@terra.com.br> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <0AF9CCEA-787E-42F3-8EFB-3CCF684A3D70@seespotcode.net> Cc: pgsql-general@postgresql.org, pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: [SQL] Setting variable Date: Mon, 18 Jun 2007 09:43:55 -0500 To: Ranieri Mazili X-Mailer: Apple Mail (2.752.2) X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/1047 X-Sequence-Number: 115870 On Jun 18, 2007, at 9:29 , Ranieri Mazili wrote: > CREATE OR REPLACE FUNCTION lost_hours_temp(date) > RETURNS text AS > $BODY$ > DECLARE > START_DATE date; > END_DATE date; > QUERY text; > BEGIN > START_DATE := $1; > END_DATE := START_DATE - interval '3 year'; > > The last line (END_DATE := START_DATE - interval '3 year';) > generate the following error: > > ERROR: operator is not unique: "unknown" / "unknown" > SQL state: 42725 > Hint: Could not choose a best candidate operator. You may need to > add explicit type casts. > Context: PL/pgSQL function "lost_hours_temp" line 10 at assignment Note that the error is at line 10. You've only shown lines 1 through 7 of the function body, so you haven't actually shown us where the error is. Michael Glaesemann grzm seespotcode net