From: hubert depesz lubaczewski <depesz@depesz.com>
To: hamann.w@t-online.de
Cc: pgsql-general@lists.postgresql.org
Subject: Re: trouble writing plpgsql
Date: Thu, 22 Dec 2022 12:43:30 +0100
Message-ID: <Y6RC4lRud32pEcPF@depesz.com> (raw)
In-Reply-To: <wolfgang-1221222123722.A0128333@linux-tuxedo>
References: <wolfgang-1221222123722.A0128333@linux-tuxedo>
On Thu, Dec 22, 2022 at 11:37:22AM -0000, hamann.w@t-online.de wrote:
> I want to make a function to parsetext and return key-value pairs
> create or replace function extractinfo (text) returns table (key char[1], val text)
Please don't use char datatype:
https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_char.28n.29> language plpgsql as $$
>
> I first tried
> declare
> xx record;
> begin
> ....
> xx.key = ....; xx.val = ....;
> return next xx:
> This is not possible because xx needs to know its structure before the fields can be assiged to.
> Could I declare xx as having these fields in the first place, do Ineedto create a type for key, val
> first?
select '...' as key, '...' as val into record;
depesz
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: depesz@depesz.com, hamann.w@t-online.de
Subject: Re: trouble writing plpgsql
In-Reply-To: <Y6RC4lRud32pEcPF@depesz.com>
References: <wolfgang-1221222123722.A0128333@linux-tuxedo> <Y6RC4lRud32pEcPF@depesz.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