Re: Character escape in "CREATE FUNCTION ..."

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Character escape in "CREATE FUNCTION ..."
Дата
Msg-id 200403151911.13260.dev@archonet.com
обсуждение исходный текст
Ответ на Character escape in "CREATE FUNCTION ..."  (Shilong Stanley Yao <yao@noao.edu>)
Список 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 по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: PostgeSQL problem (server crashed?)
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: Character escape in "CREATE FUNCTION ..."