| From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
|---|---|
| To: | stayler(at)washoecounty(dot)us |
| Cc: | PostgreSQL List <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: Creating a function with single quotes |
| Date: | 2009-02-19 16:08:52 |
| Message-ID: | 499D8414.6020002@postnewspapers.com.au |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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.
The documentation for PL/PgSQL goes into quoting in great depth. Read
that if you want to understand. However, the quick and dirty answer is
to use $$ style quoting:
create function csd_interval(integer) returns interval as $$
BEGIN
RETURN $1 * interval '1 msec'
END;
$$ LANGUAGE 'plpgsql';
--
Craig Ringer
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jasen Betts | 2009-02-20 08:11:46 | Re: Creating a function with single quotes |
| Previous Message | Adrian Klaver | 2009-02-19 16:03:08 | Fwd: Re: Creating a function with single quotes |