From: | Michael Glaesemann <grzm(at)myrealbox(dot)com> |
---|---|
To: | "Davidson, Robert" <robdavid(at)amazon(dot)com> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Using a parameter in Interval |
Date: | 2006-03-22 00:56:46 |
Message-ID: | 06F2BDC4-2FCF-44BA-9DEC-CAAC518CE678@myrealbox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mar 22, 2006, at 9:52 , Davidson, Robert wrote:
> ERROR: syntax error at or near "CAST" at character 34
>
> QUERY: SELECT current_date - INTERVAL (CAST( $1 AS varchar) || '
> weeks')
>
> CONTEXT: SQL statement in PL/PgSQL function "testing" near line 2
The generally recommended way is something like:
test=# select '4'::integer * interval '1 week';
?column?
----------
28 days
(1 row)
or the more SQL compliant:
test=# select cast('4' as integer) * interval '1 week';
?column?
----------
28 days
(1 row)
Does that work for you?
Michael Glaesemann
grzm myrealbox com
From | Date | Subject | |
---|---|---|---|
Next Message | Owen Jacobson | 2006-03-22 00:57:52 | Re: Using a parameter in Interval |
Previous Message | Davidson, Robert | 2006-03-22 00:52:45 | Using a parameter in Interval |