| From: | "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Creating a function with single quotes |
| Date: | 2009-02-20 14:13:03 |
| Message-ID: | 200902201513.03872.leif@solumslekt.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Friday 20. February 2009, Shawn Tayler wrote:
>Hello Jasen and the List,
>
>I tried the $$ quote suggestion:
>
>create function f_csd_interval(integer) returns interval as
>$$
>BEGIN
>RETURN $1 * interval '1 msec'
>END;
>$$
>LANGUAGE 'plpgsql';
>
>Here is what I got:
>
>edacs=# \i 'f_csd_interval.sql'
>psql:f_csd_interval.sql:7: ERROR: syntax error at or near "END"
>LINE 1: SELECT ( $1 * interval '1 msec') END
> ^
>QUERY: SELECT ( $1 * interval '1 msec') END
>CONTEXT: SQL statement in PL/PgSQL function "f_csd_interval" near
> line2 edacs=#
>
>The error at or near END is curious. There must be something wrong in
>the line before it but I can't see it. Suggestions?
You should place a semicolon at the end of the RETURN line, and remove
the one after END,
BTW, simple functions as this are better written in the SQL language. I
can't speak for the validity of the code itself, but you can rewrite it
as
create function f_csd_interval(integer) returns interval as $$
SELECT $1 * interval '1 msec'
$$ LANGUAGE SQL;
--
Leif Biberg Kristensen | Registered Linux User #338009
Me And My Database: http://solumslekt.org/blog/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Shawn Tayler | 2009-02-20 14:22:33 | Re: Creating a function with single quotes |
| Previous Message | Shawn Tayler | 2009-02-20 14:03:10 | Re: Creating a function with single quotes |