Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p8JtA-0002Xl-VK for pgsql-general@arkaria.postgresql.org; Thu, 22 Dec 2022 11:37:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p8Jt9-0008BV-MZ for pgsql-general@arkaria.postgresql.org; Thu, 22 Dec 2022 11:37:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p8Jt9-0008BH-CM for pgsql-general@lists.postgresql.org; Thu, 22 Dec 2022 11:37:27 +0000 Received: from mailout02.t-online.de ([194.25.134.17]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p8Jt7-0003XK-FE for pgsql-general@lists.postgresql.org; Thu, 22 Dec 2022 11:37:26 +0000 Received: from fwd87.dcpf.telekom.de (fwd87.aul.t-online.de [10.223.144.113]) by mailout02.t-online.de (Postfix) with SMTP id 9A2A91B98C for ; Thu, 22 Dec 2022 12:37:23 +0100 (CET) Received: from musicman.homeip.net ([79.200.99.234]) by fwd87.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1p8Jt4-0UjcvZ0; Thu, 22 Dec 2022 12:37:22 +0100 Received: (qmail 32353 invoked by uid 1000); 22 Dec 2022 11:37:22 -0000 Date: 22 Dec 2022 11:37:22 -0000 Subject: trouble writing plpgsql To: pgsql-general@lists.postgresql.org From: hamann.w@t-online.de Message-Id: X-Mailer: TkMail 4.0beta9 Content-type: text/plain; charset=utf-8 X-TOI-EXPURGATEID: 150726::1671709042-3B7ED81E-36731B22/0/0 CLEAN NORMAL X-TOI-MSGID: 3854348e-d4bb-4228-9902-6bab946c5d26 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, 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) 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? Wolfgang Hamann