Dynamic Query for System functions - now()

From: "Kumar" <sgnerd(at)yahoo(dot)com(dot)sg>
To: "psql" <pgsql-sql(at)postgresql(dot)org>
Subject: Dynamic Query for System functions - now()
Date: 2003-11-10 07:12:47
Message-ID: 017701c3a75a$0e3e6050$7502a8c0@hdsc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear Friends,

I am using PostgreSQL 7.3.4 Server on RH Linux 7.2. I am trying to generate a dynamic query to fetch the next month interval.

select now()+ interval'1 month'; -- This is working fine.

I wanna dynamically assign the interval number. i,e --> select now()+ interval'n month';

For this I wanted to write a dynamic query.
EXECUTE 'select now()+ interval\'' || 3|| 'month\'';
Error
ERROR: parser: parse error at or near "'select now()+ interval\''" at character 9

Help help me with this. I wanted to use this query inside a PLpgSQL function.

Regards
Kumar

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Guillaume Houssay 2003-11-10 11:18:32 FOR : control structure
Previous Message Christopher Browne 2003-11-10 02:59:14 Re: help me...