Re: Character escape in "CREATE FUNCTION ..." - Mailing list pgsql-general

From Richard Huxton
Subject Re: Character escape in "CREATE FUNCTION ..."
Date
Msg-id 200403151911.13260.dev@archonet.com
Whole thread Raw
In response to Character escape in "CREATE FUNCTION ..."  (Shilong Stanley Yao <yao@noao.edu>)
List pgsql-general
On Monday 15 March 2004 18:38, Shilong Stanley Yao 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?

> 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);

If the box constructor is supposed to take a string, try something like:

SELECT box \'((\' || $1 || \'...etc

That is to say - use string concatenation

--
  Richard Huxton
  Archonet Ltd

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: PostgeSQL problem (server crashed?)
Next
From: Bruno Wolff III
Date:
Subject: Re: Character escape in "CREATE FUNCTION ..."