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 1lOHtF-0005wd-DT for pgsql-sql@arkaria.postgresql.org; Mon, 22 Mar 2021 10:34:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lOHtE-0007y4-1t for pgsql-sql@arkaria.postgresql.org; Mon, 22 Mar 2021 10:34:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lOHtD-0007xx-RR for pgsql-sql@lists.postgresql.org; Mon, 22 Mar 2021 10:34:27 +0000 Received: from hub.ringways.co.uk ([88.211.105.30] helo=ringways.co.uk) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lOHt7-0006vk-BY for pgsql-sql@lists.postgresql.org; Mon, 22 Mar 2021 10:34:26 +0000 Received: from rwsys1.ringways.co.uk ([10.1.1.105] helo=eddie.ringways.co.uk) by ringways.co.uk with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lOHt0-0003UF-TD for pgsql-sql@lists.postgresql.org; Mon, 22 Mar 2021 10:34:15 +0000 Subject: Re: select into composite type / return To: pgsql-sql@lists.postgresql.org References: <39dcfab9-4eb2-382b-9186-baf722ca56a0@ringways.co.uk> <3523853.1616002010@sss.pgh.pa.us> <9eb42b06-9cfa-1e4b-e42b-6f64e99675a5@ringways.co.uk> <7af5d693-a6a3-d3d4-050a-0898aad8bd77@ringways.co.uk> <3718235.1616077713@sss.pgh.pa.us> From: Gary Stainburn Message-ID: <9fb9f646-58be-cb17-b144-664c46f6cd01@ringways.co.uk> Date: Mon, 22 Mar 2021 10:34:13 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Score: -48.8 (------------------------------------------------) X-Spam-Report: Spam detection software, running on the system "ollie2.ringways.co.uk", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see Gary Stainburn for details. Content preview: I've added another function, partly to aid debugging, partly to test the next part of the project. The idea is simple. select the results of the calculation into a local variable and then process it. However, I can't get the select to work. The failure message relates to the "select into D" line. [...] Content analysis details: (-48.8 points, 15.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -50 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 2.0 FLOWED Conten Type format=flowed appears in the new SPAMS 0.1 SCORE_RCPTS Adding score for each recipient -1.0 AWL AWL: Adjusted score from AWL reputation of From: address 1.0 MISSING_FROM Missing From: header -0.0 NICE_REPLY_A Looks like a legit reply (A) 1.0 RING_SAFE No description available. List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I've added another function, partly to aid debugging, partly to test the next part of the project. The idea is simple.  select the results of the calculation into a local variable and then process it.  However, I can't get the select to work.  The failure message relates to the "select into D" line. gary=# select * from read_breakdown(1); ERROR:  invalid input syntax for type numeric: "(1.00,2.00,3.00,4.00,5.00,6.00)" CONTEXT:  PL/pgSQL function read_breakdown(integer) line 12 at SQL statement gary=# create or replace function read_breakdown(vID int4)  RETURNS breakdown AS $$ DECLARE   v RECORD;   D breakdown; BEGIN   IF vID IS NULL THEN RETURN NULL; END IF;   select into v * from sessions s where s.ID = vID;   IF NOT FOUND THEN     RAISE NOTICE 'breakdown: % not found',vID;     RETURN NULL;   END IF;   select into D do_breakdown(v.v1,v.v2,v.v3,v.v4,v.v5,v.v6,v.v7);   IF NOT FOUND THEN     RAISE NOTICE 'breakdown: % calculation failed',vID;     RETURN NULL;   END IF;   RAISE NOTICE 'read_breakdown: f1=%',D.f1;   RAISE NOTICE 'read_breakdown: f2=%',D.f2;   RAISE NOTICE 'read_breakdown: f3=%',D.f3;   RAISE NOTICE 'read_breakdown: f4=%',D.f4;   RAISE NOTICE 'read_breakdown: f5=%',D.f5;   RAISE NOTICE 'read_breakdown: f6=%',D.f6;   RETURN D; END; $$ LANGUAGE PLPGSQL;