pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roberto Mello <rmello@cc.usu.edu>
To: Edward Grabczewski <edward.grabczewski@btinternet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: PL/pgSQL syntax for strings
Date: Thu, 1 Nov 2001 12:56:32 -0700
Message-ID: <20011101125632.A20330@cc.usu.edu> (raw)
In-Reply-To: <9rru48$8gh$1@news.tht.net>
References: <9rru48$8gh$1@news.tht.net>

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.



view thread (4+ messages)  latest in thread

Message-ID: <20011101125632.A20330@cc.usu.edu>
Permalink:  ../20011101125632.A20330@cc.usu.edu/
Also on:    postgresql.org/message-id/20011101125632.A20330@cc.usu.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rmello@cc.usu.edu, edward.grabczewski@btinternet.com
  Subject: Re: PL/pgSQL syntax for strings
  In-Reply-To: <20011101125632.A20330@cc.usu.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox