pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: how to concat/concat_ws all fields without braces
Date: Sat, 15 Jun 2019 16:20:38 +0200
Message-ID: <20190615142038.GJ10179@protected.rcdrun.com> (raw)
In-Reply-To: <CAFj8pRAKcK96oXzTtR3+wWWi-FD2Tfr0bm89GsVWG9FzrNkA9g@mail.gmail.com>
References: <20190615061957.GD2565@protected.rcdrun.com>
	<CAFj8pRAKcK96oXzTtR3+wWWi-FD2Tfr0bm89GsVWG9FzrNkA9g@mail.gmail.com>

Dear Pavel,

Ahoj.

* Pavel Stehule <pavel.stehule@gmail.com> [2019-06-15 11:37]:
> you can write own function that will do what you want
> 
> create or replace function rec_concat_fields(record, text)
> returns text as $$
>   begin
>     return string_agg(value, '|') from json_each_text(row_to_json($1));
>   end
> $$ language plpgsql;
> 
> postgres=# select rec_concat_fields(foo.*, '*') from foo;
> ┌───────────────────┐
> │ rec_concat_fields │
> ╞═══════════════════╡
> │ ahoj|svete        │
> └───────────────────┘
> (1 row)
> 

I have tried that one, not working quite;

create or replace function concat_fields(record, text)
returns text as $$
  begin
    return string_agg(value, ' ') from json_each_text(row_to_json($1));
  end
$$ language plpgsql;
rcdbusiness$# ERROR:  PL/pgSQL functions cannot accept type record

Jean





view thread (6+ messages)  latest in thread

Message-ID: <20190615142038.GJ10179@protected.rcdrun.com>
Permalink:  ../20190615142038.GJ10179@protected.rcdrun.com/
Also on:    postgresql.org/message-id/20190615142038.GJ10179@protected.rcdrun.com

 · 

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-general@postgresql.org
  Cc: bugs@gnu.support, pavel.stehule@gmail.com
  Subject: Re: how to concat/concat_ws all fields without braces
  In-Reply-To: <20190615142038.GJ10179@protected.rcdrun.com>
  References: <20190615061957.GD2565@protected.rcdrun.com> <CAFj8pRAKcK96oXzTtR3+wWWi-FD2Tfr0bm89GsVWG9FzrNkA9g@mail.gmail.com> <20190615142038.GJ10179@protected.rcdrun.com>

* 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