public inbox for [email protected]  
help / color / mirror / Atom feed
From: Merlin Moncure <[email protected]>
To: PALAYRET Jacques <[email protected]>
Cc: [email protected]
Subject: Re: PostgreSQL include directive in plpgsql language PL/pgSQL
Date: Mon, 8 Sep 2025 10:31:52 -0600
Message-ID: <CAHyXU0wz3i=xgSKzMfoC_57Ya3m2FO=Y=rzmLVcWEJF=hWv4cw@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<CAHyXU0zNE3CuPs2433GZtVh9SbrkyTUwGmAiy+yJuhz484gPUw@mail.gmail.com>
	<[email protected]>

On Mon, Sep 8, 2025 at 3:37 AM PALAYRET Jacques <[email protected]>
wrote:

> Hello,
> Thanks for your response.
>
> # Currently, I have a function text and a function array with *the same
> body* but a *distinct type return*.
> -> Example with the array of text function :
> SELECT public.calfxi3s_all_elements_text_array(12345678, '2025-01-01
> 00:00') ;
>                     calfxi3s_all_elements_text_array
> -------------------------------------------------------------------------
>  {3.2,sonic,"Capteur Vent ultrasonique compact Brand xxx",2,-0.123,0.321}
> That gives some parameters : the value of the wind strength (3.2), the
> kind of sensor (sonic), the model (Capteur ...), the environmment (2), two
> coefficients (-0.123,0.321)
>

Right.  I guess your issue might be in calfxi3s_all_elements_text_array().

Is there any specific reason why this must return an array vs a composite
type?  I guess the basic issue here is trying to abuse the array type when
a composite type might have many advantages here.

CREATE TYPE sensor_measurement_t AS
(
  wind_strength numeric,
  sensor text,
  model text,
  environment int,
  coefficient1 numeric,
  coefficient2 numeric
);

CREATE FUNCTION calfxi3s_all_elements(...) RETURNS sensor_measurement_t  AS
..


SELECT * FROM calfxi3s_all_elements(...);
SELECT model FROM calfxi3s_all_elements(...);

melin


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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: PostgreSQL include directive in plpgsql language PL/pgSQL
  In-Reply-To: <CAHyXU0wz3i=xgSKzMfoC_57Ya3m2FO=Y=rzmLVcWEJF=hWv4cw@mail.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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox