Re: Help with quotes in plpgsql - Mailing list pgsql-sql

From A. Kretschmer
Subject Re: Help with quotes in plpgsql
Date
Msg-id 20061219211817.GA32044@a-kretschmer.de
Whole thread Raw
In response to Help with quotes in plpgsql  (Richard Ray <rray@mstc.state.ms.us>)
List pgsql-sql
am  Tue, dem 19.12.2006, um 14:09:37 -0600 mailte Richard Ray folgendes:
> 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

test=# create or replace function test(int) returns date as $$begin return current_date-($1||'days')::interval; end;$$
languageplpgsql;
 
CREATE FUNCTION
test=# select test(4);   test
------------2006-12-15
(1 row)

test=# select test(3);   test
------------2006-12-16
(1 row)


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47215,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net


pgsql-sql by date:

Previous
From: Richard Ray
Date:
Subject: Re: Help with quotes in plpgsql
Next
From: "Milen A. Radev"
Date:
Subject: Re: Help with quotes in plpgsql