From: | Christoph Haller <ch(at)rodos(dot)fzk(dot)de> |
---|---|
To: | sgnerd(at)yahoo(dot)com(dot)sg ("Kumar") |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Dynamic Query for System functions - now() |
Date: | 2003-11-10 11:37:15 |
Message-ID: | 200311101037.LAA29518@rodos |
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()+ inter=
> val'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 functio=
> n.
>
> Regards
> Kumar
>
You'd probably want to use the to_char() function like this
EXECUTE 'select now()+ interval\'' ||to_char(3,'9')|| 'month\'';
The || operator is the string concatination operator.
Regards, Christoph
From | Date | Subject | |
---|---|---|---|
Next Message | Kumar | 2003-11-10 11:57:11 | Re: Dynamic Query for System functions - now() |
Previous Message | Guillaume Houssay | 2003-11-10 11:24:55 | FOR : Structure control pb |