Re: PL/pgSQL syntax for strings

From: Roberto Mello <rmello(at)cc(dot)usu(dot)edu>
To: Edward Grabczewski <edward(dot)grabczewski(at)btinternet(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: PL/pgSQL syntax for strings
Date: 2001-11-01 19:56:32
Message-ID: 20011101125632.A20330@cc.usu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Oleg Lebedev 2001-11-01 21:04:12 table permissions
Previous Message Stephan Szabo 2001-11-01 19:38:56 Re: Error 34526 - cache lookup failed