HiveBrain v1.2.0
Get Started
← Back to all entries
gotchasqlMinor

What is the difference between RETURNS `SETOF integer` and RETURNS TABLE(name int)`?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
thewhatsetofdifferencebetweennamereturnsandintinteger

Problem

Given the two definitions below, is there any difference?
CREATE FUNCTION foo(OUT foobar int4)
RETURNS SETOF int4
AS 'MODULE_PATHNAME', 'foo'
LANGUAGE C STRICT VOLATILE;


And,
CREATE FUNCTION foo()
RETURNS TABLE(foobar int4)
AS 'MODULE_PATHNAME', 'foo'
LANGUAGE C STRICT VOLATILE;


That is to say is there a difference between the "Result data type" as displayed with \df between

  • TABLE(foobar integer)



  • and, SETOF interger where the Argument data types includes OUT foobar integer

Solution

The docs say this on CREATE FUNCTION

The name of an output column in the RETURNS TABLE syntax. This is effectively another way of declaring a named OUT parameter, except that RETURNS TABLE also implies RETURNS SETOF.

Context

StackExchange Database Administrators Q#302239, answer score: 3

Revisions (0)

No revisions yet.