pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Edward Grabczewski <edward.grabczewski@btinternet.com>
To: pgsql-sql@postgresql.org
Subject: Re: PL/pgSQL syntax for strings
Date: Fri, 2 Nov 2001 03:45:19 -0000
Message-ID: <9rt4jd$u4r$1@news.tht.net> (raw)
References: <20011101125632.A20330@cc.usu.edu>

Sorry about the function not makig sense. It's only half-baked until I get
this string thing sorted out. I left the hard-coded numerical values there
for testing purposes only - so I guess it confused everyone. As it happens
the syntax of the posted function actually works. Even the backslashes! Now
the trick is to incorporate the variables into the string. I've looked at
the documentation a few times and I've experimented but failed to get the
right syntax so far - which is why I thought I'd ask for some help. :-)

Below is what the function will eventually look like when it uses the proper
variables: I guessed that the single quote needs to be double quoted:

''''('' x1 '','' z1 ''), ('' x2 '','' z2 '')''''

or something like that. Should this work?

Eddy


CREATE TABLE rtest (
                                     xz BOX,
                                     yz BOX,
                                     xy BOX);

CREATE INDEX rtest_xz_index ON rtest USING RTREE (xz bigbox_ops);
CREATE INDEX rtest_yz_index ON rtest USING RTREE (yz bigbox_ops);
CREATE INDEX rtest_xy_index ON rtest USING RTREE (xy bigbox_ops);

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 ( '(x1,z1), (x2,z2)',
                        '(y1,y2), (y2,z2)',
                        '(x1,y1), (x2,y2)');
      RETURN null;
    END;'
LANGUAGE 'plpgsql';

SELECT threedpoint(100,200,300,400,500,600);







view thread (4+ messages)  latest in thread

Message-ID: <9rt4jd$u4r$1@news.tht.net>
Permalink:  ../9rt4jd$u4r$1@news.tht.net/
Also on:    postgresql.org/message-id/9rt4jd$u4r$1@news.tht.net

 · 

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: edward.grabczewski@btinternet.com
  Subject: Re: PL/pgSQL syntax for strings
  In-Reply-To: <9rt4jd$u4r$1@news.tht.net>

* 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