| From: | Agustin Bialet <abialet(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL List <pgsql-sql(at)postgresql(dot)org> |
| Cc: | stayler(at)washoecounty(dot)us |
| Subject: | Re: Creating a function with single quotes |
| Date: | 2009-02-19 16:00:32 |
| Message-ID: | 796C5BE3-5184-4ED8-BE8C-4CA267F3D313@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Feb 19, 2009, at 1:41 PM, Shawn Tayler wrote:
> Hello,
>
> This has me befuddled. I am trying create a simple experiment, rather
> new to SQL and I am running into an issue with single quotes. All I
> can
> find on creating a function states the procedure should be contained
> within single quotes. My problem comes when I want to use a textual
> representation of an interval.
>
> create function csd_interval(integer) returns interval as
> 'BEGIN
> RETURN $1 * interval '1 msec'
> END;'
> LANGUAGE 'plpgsql';
>
> it always fails at the '1 msec' point.
>
Try using:
create function csd_interval(integer) returns interval as $$
BEGIN
RETURN $1 * interval '1 msec'
END;
$$ LANGUAGE 'plpgsql';
For more info refer to section 4.1.2.2. Dollar-Quoted String Constants
in the manual.
Agustin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2009-02-19 16:03:08 | Fwd: Re: Creating a function with single quotes |
| Previous Message | Shawn Tayler | 2009-02-19 15:41:11 | Creating a function with single quotes |