From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Shilong Stanley Yao <yao(at)noao(dot)edu> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Character escape in "CREATE FUNCTION ..." |
Date: | 2004-03-15 19:33:12 |
Message-ID: | 20040315193312.GA30682@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Mar 15, 2004 at 11:38:05 -0700,
Shilong Stanley Yao <yao(at)noao(dot)edu> wrote:
> Dear All,
> I am trying to write a function in Postgresql, which takes 2 floats and
> returns a box. But seems the nested single-quote in the AS clause
> prevent $1 and $2 from being expanded. Besides writing a C function
> instead of a SQL one, is there any way to solve this problem?
I believe you want to concatenate $1 and $2 with the constants parts
of the string rather than to embed them in the string.
The cube type in contrib/cube already has functions for making a cube
from float8 numbers without converting to text inbetween. Depending
on what you want this might be another approach for you.
>
> Thanks a lot.
> -Stan
>
> CREATE OR REPLACE FUNCTION func_radec_to_box(float, float) RETURNS box
> AS 'SELECT box \'(($1, $2), (1.3, 1.4))\''
> LANGUAGE 'sql'
> WITH (ISCACHABLE);
>
>
> Error message:
> psql:func_radec_to_box.sql:4: ERROR: Bad box external representation
> '(($1, $2), (1.3, 1.4))'
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
From | Date | Subject | |
---|---|---|---|
Next Message | Mage | 2004-03-15 19:36:25 | Re: boolean to int |
Previous Message | Richard Huxton | 2004-03-15 19:11:13 | Re: Character escape in "CREATE FUNCTION ..." |