Re: PL/pgSQL syntax for strings

Поиск
Список
Период
Сортировка
От Roberto Mello
Тема Re: PL/pgSQL syntax for strings
Дата
Msg-id 20011101125632.A20330@cc.usu.edu
обсуждение исходный текст
Ответ на PL/pgSQL syntax for strings  ("Edward Grabczewski" <edward.grabczewski@btinternet.com>)
Список pgsql-sql
On Thu, Nov 01, 2001 at 04:48:29PM +0000, Edward Grabczewski wrote:
> 
> DROP FUNCTION threedpoint (float,float,float, float,float,float);
> CREATE FUNCTION threedpoint (float,float,float,float,float,float)
> RETURNS text
> AS 'DECLARE
>       x1 ALIAS FOR $1;
>       y1 ALIAS FOR $2;
>       z1 ALIAS FOR $3;
>       x2 ALIAS FOR $4;
>       y2 ALIAS FOR $5;
>       z2 ALIAS FOR $6;
>     BEGIN
>       INSERT INTO rtest(xz,yz,xy)
>       VALUES ( \'(0,2), (1,3)\',
>                         \'(1,2), (2,3)\',
>                         \'(0,1), (1,2)\');
>       RETURN null;
>     END;'
> LANGUAGE 'plpgsql';
> 
> SELECT threedpoint(100,200,300,400,500,600);

Why do you pass all those variables to the function if you don't use them?
It doesn't make any sense to me.

As the documentation for PL/pgSQL clearly states with several examples,
you have to double the quotes in strings>

INSERT INTO rtest(xz,yz,xy)
VALUES (''(0,2), (1,3)'',       ''(1,2), (2,3)'',       ''(0,1), (1,2)'');

I don't know if the \' way of escaping quotes works. I never tried within
a PL/pgSQL function. My guess is that it doesn't.

-Roberto
-- 
+----| http://fslc.usu.edu USU Free Software & GNU/Linux Club |------+ Roberto Mello - Computer Science, USU -
http://www.brasileiro.net      http://www.sdl.usu.edu - Space Dynamics Lab, Developer    
 
My inferiority complexes aren't as good as yours.


В списке pgsql-sql по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Error 34526 - cache lookup failed
Следующее
От: Oleg Lebedev
Дата:
Сообщение: table permissions