Re: trouble writing plpgsql

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема Re: trouble writing plpgsql
Дата
Msg-id Y6RC4lRud32pEcPF@depesz.com
обсуждение исходный текст
Ответ на trouble writing plpgsql  (hamann.w@t-online.de)
Список pgsql-general
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



В списке pgsql-general по дате отправления:

Предыдущее
От: hamann.w@t-online.de
Дата:
Сообщение: trouble writing plpgsql
Следующее
От: David Gilman
Дата:
Сообщение: Re: Implementing foreign data wrappers and avoiding n+1 querying