Database Reference
In-Depth Information
But when trying to do it this way, we get an error:
ERROR: parameter name "a" used more than once
CONTEXT: compilation of PL/pgSQL function
"permutations2" near line 1
This error hints that the fields in the return table definition are also actually just OUT
parameters and the whole RETURNS TABLE syntax is just another way to spell
CREATE FUNCTION f(OUT ..., OUT...) RETURNS RECORD … .
This can be further verified by changing input parameters so that the definition can
be fed into PostgreSQL:
CREATE FUNCTION permutations2(ia int, ib int,
ic int)
RETURNS TABLE(a int, b int, c int)
AS $$
BEGIN
RETURN NEXT a,b,c;
END;
$$ LANGUAGE plpgsql;
And when we try to create this, we get the following output:
ERROR: RETURN NEXT cannot have a parameter in
function with OUT parameters
LINE 5: RETURN NEXT a,b,c;
^
So yes, the fields of the table in the RETURNS definition are actually just OUT para-
meters. We can try one last thing to get the function to construct the return structure
in the RETURN NEXT clause.
CREATE TYPE abc AS (a int, b int, c int);
CREATE FUNCTION permutations2(ia int, ib int,
Search WWH ::




Custom Search