Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 3F7A19F946C for ; Tue, 19 Dec 2006 16:35:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 35646-08 for ; Tue, 19 Dec 2006 16:35:20 -0400 (AST) X-Greylist: delayed 00:17:37.480038 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id E21929FA373 for ; Tue, 19 Dec 2006 16:35:27 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mis010-1.exch010.intermedia.net (mis010-1.exch010.intermedia.net [64.78.61.91]) by svr4.postgresql.org (Postfix) with ESMTP id 7315A5AF8CC for ; Tue, 19 Dec 2006 20:17:49 +0000 (GMT) Received: from ehost010-33.exch010.intermedia.net ([64.78.20.173]) by mis010-1.exch010.intermedia.net with Microsoft SMTPSVC(6.0.3790.1830); Tue, 19 Dec 2006 12:17:47 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C723AA.5CBDEAC4" Subject: Re: Help with quotes in plpgsql Date: Tue, 19 Dec 2006 12:17:46 -0800 Message-ID: <8C5B026B51B6854CBE88121DBF097A866A48FD@ehost010-33.exch010.intermedia.net> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] Help with quotes in plpgsql Thread-Index: AccjqWEsBmGsL2soRwiGQVA9LkL3dQAARu/g From: "Hector Villarreal" To: "Richard Ray" , X-OriginalArrivalTime: 19 Dec 2006 20:17:47.0155 (UTC) FILETIME=[BFBC4E30:01C723AA] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/144 X-Sequence-Number: 27100 This is a multi-part message in MIME format. ------_=_NextPart_001_01C723AA.5CBDEAC4 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Not sure about $1 parms : you may need to use a variable to set $1 to then cast it as interval :=20 =20 =20 create or replace function test(integer) returns setof text as $$ declare a record; begin select into a now() - ($1::text||'days')::interval; return next a; return; end $$ language 'plpgsql'; =20 -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Richard Ray Sent: Tuesday, December 19, 2006 12:10 PM To: pgsql-sql@postgresql.org Subject: [SQL] Help with quotes in plpgsql =20 How should this be properly quoted =20 create or replace function test(integer) returns setof text as $$ declare a record; begin select into a now() - interval '$1 day'; return next a; return; end $$ language 'plpgsql'; =20 I'm not having a lot of luck Thanks Richard =20 ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at =20 http://www.postgresql.org/about/donate ------_=_NextPart_001_01C723AA.5CBDEAC4 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Not sure about $1 parms : you may need to use a variable to = set $1 to then cast it as interval :

 

 

create or replace function test(integer) returns setof text as = $$

declare

   a record;

begin

   select into a now() - ($1::text||'days')::interval;<= /o:p>

   return next a;

   return;

end

$$ language 'plpgsql';

 

-----Original Message-----
From: pgsql-sql-owner@postgresql.org = [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Richard Ray
Sent: Tuesday, December 19, 2006 12:10 PM
To: pgsql-sql@postgresql.org
Subject: [SQL] Help with quotes in plpgsql

 

How should this be properly quoted

 

create or replace function test(integer) returns setof text as = $$

declare

   a record;

begin

   select into a now() - interval '$1 = day';

   return next a;

   return;

end

$$ language 'plpgsql';

 

I'm not having a lot of luck

Thanks

Richard

 

---------------------------(end of broadcast)---------------------------

TIP 7: You can help support the PostgreSQL project by donating = at

 

           = ;     = http://www.postgresql.org/about/donate

------_=_NextPart_001_01C723AA.5CBDEAC4--