I hunted online and through documentation, but that a lot of A more common use seems to be returning a SETOF of a certain row type, not just a single row.
The following use case is trivial for illustration, as I am just trying to determine if this is possible in plpgsql and to understand the syntax to be used if it is. (Just as the Postgresql documentation contains examples of functions for returning a static set of fixed values, the point here is not the use case, but the syntax.)
With this table:
create table my_table (f1 int primary key, f2 text, f3 real, f4 text, f5 bool);
The following function can be created:
create function my_func1(f1_to_look_up int) returns my_table
as $$ select * from my_table where f1 = f1_to_look_up $$;
This can also be done in plpgsql with explicit out parameters (and with
f1 expressly stated in the
where Clause to avoid ambiguity):
create function my_func2(f1_to_look_up int, out f1 int, out f2 text, out f3 real, out f4 text, out f5 bool)
select * into strict f1, f2, f3, f4, f5
from my_table where my_table.f1 = f1_to_look_up;
Is there any way to do the same in plpgsql without having to repeat the definition of?
my_table to list all OUT parameters?