Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hc9Y5-0008J6-GA for pgsql-general@arkaria.postgresql.org; Sat, 15 Jun 2019 14:20:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hc9Y3-0000Eh-51 for pgsql-general@arkaria.postgresql.org; Sat, 15 Jun 2019 14:20:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hc9Y2-0000Ea-Nn for pgsql-general@lists.postgresql.org; Sat, 15 Jun 2019 14:20:50 +0000 Received: from stw1.rcdrun.com ([217.170.207.13]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hc9Xw-0002jt-2w for pgsql-general@lists.postgresql.org; Sat, 15 Jun 2019 14:20:49 +0000 Received: from protected.rcdrun.com (localhost [::1]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA; Sat, 15 Jun 2019 07:20:39 -0700 id 000000000005DD38.000000005D04FEB7.00003B0E Received: from localhost (protected.rcdrun.com [local]) by protected.rcdrun.com (OpenSMTPD) with ESMTPA id 9e56b518; Sat, 15 Jun 2019 14:20:38 +0000 (UTC) Date: Sat, 15 Jun 2019 16:20:38 +0200 From: Jean Louis To: Pavel Stehule Cc: pgsql-general Subject: Re: how to concat/concat_ws all fields without braces Message-ID: <20190615142038.GJ10179@protected.rcdrun.com> References: <20190615061957.GD2565@protected.rcdrun.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: START YOUR OWN GOLD MINE User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Dear Pavel, Ahoj. * Pavel Stehule [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