Re: Help with quotes in plpgsql

From: "Milen A(dot) Radev" <milen(at)radev(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Help with quotes in plpgsql
Date: 2006-12-19 22:54:13
Message-ID: 45886D95.5080300@radev.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Richard Ray написа:
> On Tue, 19 Dec 2006, Milen A. Radev wrote:
>
>> Richard Ray ÿÿÿÿÿÿÿÿÿÿÿÿ:
>>> 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
>>
>>
>> Welcome to psql 8.2.0, the PostgreSQL interactive terminal.
>>
>> Type: \copyright for distribution terms
>> \h for help with SQL commands
>> \? for help with psql commands
>> \g or terminate with semicolon to execute query
>> \q to quit
>>
>> milen=> create or replace function test(integer) returns setof text as $$
>> milen$> declare
>> milen$> a record;
>> milen$> begin
>> milen$> select into a now() - interval '$1 day';
>> milen$> return next a;
>> milen$> return;
>> milen$> end
>> milen$> $$ language 'plpgsql';
>> CREATE FUNCTION
>> milen=>
>>
>>
>>
>> No problems here. What version are you using?
>>
>
> I'm using 8.1.0 but I don't think that's the problem
> I have no problem creating the function but it will only substract 1 day

Sorry about that - I have not understand your problem.

In addition to the solution already proposed you could use "EXECUTE".
See more info here -
http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
.

--
Milen A. Radev

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Hector Villarreal 2006-12-20 00:00:00 Re: Help with quotes in plpgsql
Previous Message Richard Ray 2006-12-19 21:02:57 Re: Help with quotes in plpgsql