pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andy Corteen <lbc@telecam.demon.co.uk>
To: juerg.rietmann@pup.ch
Cc: pgsql-sql@postgresql.org
Subject: Re: Re: Still don't know how to build this string ? how to concat ??
Date: Tue, 27 Mar 2001 15:22:37 +0100
Message-ID: <14918780083.20010327152237@telecam.demon.co.uk> (raw)
In-Reply-To: <OFE5DBC589.2179BDB8-ONC1256A1C.0032B55B@pup.ch>
References: <OFE5DBC589.2179BDB8-ONC1256A1C.0032B55B@pup.ch>

Tuesday, March 27, 2001, 10:20:18 AM, you wrote:

jrpc> <snip...>

jrpc> Result:
jrpc> 01   1440
jrpc> 02   1460
jrpc> 03   1398

jrpc> The values (1440, ...) are the last entries of z_u_umfang for each z_u_typ.
jrpc> This is correct since in the function the list:= ... is overwritten until
jrpc> the last record is read.
jrpc> When I try to concat the list in the manner of list := list ||
jrpc> text(rec.z_u_umfang); the zustring is empty !

jrpc> Thanks for any help ... jr

jrpc> Query :
jrpc> select distinct z_u_typ, buildString(z_u_typ) as zustring from
jrpc> zylinder_umfang

jrpc> Function:
jrpc> CREATE FUNCTION buildString(bpchar) RETURNS text AS '
jrpc>         DECLARE
jrpc>                 list           text;
jrpc>                 rec          record;
jrpc>         BEGIN
jrpc>           FOR rec IN SELECT z_u_umfang FROM zylinder_umfang WHERE z_u_typ
jrpc> = $1;
jrpc>              list := text(rec.z_u_umfang);
jrpc>           END LOOP;
jrpc>           RETURN list;
jrpc>         END;
jrpc> ' LANGUAGE 'plpgsql';

You seem to be constantly re-assigning "list", rather than adding to
it with each iteration of the "for loop".

Would:
  ...
  list := list || ',' || text(rec.z_u_umfang)
  ...
be what your solution is missing?

-- 
Best regards,
 Andy                            mailto:lbc@telecam.demon.co.uk





view thread (9+ messages)  latest in thread

Message-ID: <14918780083.20010327152237@telecam.demon.co.uk>
Permalink:  ../14918780083.20010327152237@telecam.demon.co.uk/
Also on:    postgresql.org/message-id/14918780083.20010327152237@telecam.demon.co.uk

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: lbc@telecam.demon.co.uk, juerg.rietmann@pup.ch
  Subject: Re: Still don't know how to build this string ? how to concat ??
  In-Reply-To: <14918780083.20010327152237@telecam.demon.co.uk>
  References: <OFE5DBC589.2179BDB8-ONC1256A1C.0032B55B@pup.ch> <14918780083.20010327152237@telecam.demon.co.uk>

* 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