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 1ov0ut-0006jm-SR for pgsql-general@arkaria.postgresql.org; Tue, 15 Nov 2022 18:44:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ov0ur-0005Gd-CW for pgsql-general@arkaria.postgresql.org; Tue, 15 Nov 2022 18:44:13 +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 1ov0ur-0005GU-1p for pgsql-general@lists.postgresql.org; Tue, 15 Nov 2022 18:44:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ov0uk-00047Z-GC for pgsql-general@lists.postgresql.org; Tue, 15 Nov 2022 18:44:12 +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 2AFIi3rY1177305; Tue, 15 Nov 2022 13:44:03 -0500 From: Tom Lane To: Frank Cazabon cc: pgsql-general@lists.postgresql.org Subject: Re: Calling function from VFP changes character field to Memo In-reply-to: References: Comments: In-reply-to Frank Cazabon message dated "Tue, 15 Nov 2022 13:44:13 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1177303.1668537843.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 15 Nov 2022 13:44:03 -0500 Message-ID: <1177304.1668537843@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Frank Cazabon writes: > If however I have a function defined like this > CREATE OR REPLACE FUNCTION public.testfunction( >     ) >     RETURNS TABLE >     ( >         Firstname character(30) >     ) >     LANGUAGE 'plpgsql' > AS $BODY$ > BEGIN >     RETURN QUERY SELECT p.cFirstName FROM patients p; > END; > $BODY$; > And I call: > SELECT * FROM public.testFunction(); > Then FirstName returns as a Memo field (similar to a Text field). This is mostly about whatever software stack you're using on the client side --- Memo is certainly not something Postgres knows about. > Any idea what I need to do to get it to return the character(30) type? There's no chance of getting back the "30" part with this structure, because function signatures do not carry length restrictions. What I expect is happening is that you get firstname as an unspecified-length "character" type, and something on the client side is deciding to cope with that by calling it "Memo" instead. You could perhaps work around that by defining a named composite type: create type testfunction_result as (firstname character(30), ...); create function testfunction() returns setof testfunction_result as ... regards, tom lane