Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ron9w-003Nb5-KG for pgsql-sql@arkaria.postgresql.org; Mon, 25 Mar 2024 16:26:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ron9v-005pv5-2L for pgsql-sql@arkaria.postgresql.org; Mon, 25 Mar 2024 16:26:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ron9u-005pux-Pv for pgsql-sql@lists.postgresql.org; Mon, 25 Mar 2024 16:26:51 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ron9o-006QrU-FU for pgsql-sql@lists.postgresql.org; Mon, 25 Mar 2024 16:26:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 42PGQh0Y2499068; Mon, 25 Mar 2024 12:26:43 -0400 From: Tom Lane To: Russell Rose | Passfield Data Systems cc: "pgsql-sql@lists.postgresql.org" Subject: Re: Get error when calling function that returns a table In-reply-to: References: Comments: In-reply-to Russell Rose | Passfield Data Systems message dated "Mon, 25 Mar 2024 15:43:11 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2499066.1711384003.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 25 Mar 2024 12:26:43 -0400 Message-ID: <2499067.1711384003@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Russell Rose | Passfield Data Systems writes= : > I have got a procedure (test.sql) and this calls a function (test_rr.sql= ) which returns a table. I use the SQL: > Call test(); > I get the error: > ERROR: invalid input syntax for type integer: "(14891,0,"VIMALBA ","P901= ",111.000000)" > CONTEXT: PL/pgSQL function test() line 13 at FETCH > SQL state: 22P02 Didn't test, but I think this: DECLARE my_cur scroll CURSOR FOR SELECT test_rr() ; needs to be more like DECLARE my_cur scroll CURSOR FOR SELECT * FROM test_rr() ; As you have it, the cursor produces a single composite column, which isn't consistent with FETCH FROM my_cur INTO ret1, ret2, ret3, ret4, ret5 ; I vaguely recall that plpgsql will sometimes let you be sloppy about composites versus separate columns, but evidently not here. regards, tom lane