pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Frank Cazabon <frank.cazabon@gmail.com>
To: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Calling function from VFP changes character field to Memo
Date: Tue, 15 Nov 2022 15:07:16 -0400 (AST)
Message-ID: <d5ff6fec-9588-4d0c-9092-f064c867eeec@gmail.com> (raw)
In-Reply-To: <81af1ec5-de31-03c6-96c4-fd70f12297a8@gmail.com>
References: <fe531f0e-ff0f-9227-c879-b875dc1201d8@gmail.com>
	<1177304.1668537843@sss.pgh.pa.us>
	<7dc224a2-df53-de4a-42a6-a61502c71d95@gmail.com>
	<81af1ec5-de31-03c6-96c4-fd70f12297a8@gmail.com>

I don't think that's necessary, I'm 100% certain that it's VFP not able to interpret the size of what is coming back to it so it just gives it the biggest type it can.

Thanks

15 Nov 2022 14:59:59 Ron <ronljohnsonjr@gmail.com>:

> On 11/15/22 12:54, Frank Cazabon wrote:
>> 
>> On 15/11/2022 2:44 pm, Tom Lane wrote:
>>> Frank Cazabon <frank.cazabon@gmail.com> 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
>> Thanks, so I could define the function like this - removed the (30):
>> 
>> CREATE OR REPLACE FUNCTION public.testfunction(
>>      )
>>      RETURNS TABLE
>>      (
>>          Firstname character
>>      )
>>      LANGUAGE 'plpgsql'
>> 
>> I'll try the type definition and see if that helps.
> 
> I think you should try the original function in psql.  That will delineate Postgresql from framework.
> 
> -- 
> Angular momentum makes the world go 'round.





view thread (11+ messages)  latest in thread

Message-ID: <d5ff6fec-9588-4d0c-9092-f064c867eeec@gmail.com>
Permalink:  ../d5ff6fec-9588-4d0c-9092-f064c867eeec@gmail.com/
Also on:    postgresql.org/message-id/d5ff6fec-9588-4d0c-9092-f064c867eeec@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: frank.cazabon@gmail.com, ronljohnsonjr@gmail.com
  Subject: Re: Calling function from VFP changes character field to Memo
  In-Reply-To: <d5ff6fec-9588-4d0c-9092-f064c867eeec@gmail.com>
  References: <fe531f0e-ff0f-9227-c879-b875dc1201d8@gmail.com> <1177304.1668537843@sss.pgh.pa.us> <7dc224a2-df53-de4a-42a6-a61502c71d95@gmail.com> <81af1ec5-de31-03c6-96c4-fd70f12297a8@gmail.com> <d5ff6fec-9588-4d0c-9092-f064c867eeec@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox