Database Reference
In-Depth Information
ic int)
RETURNS SETOF abc
AS $$
BEGIN
RETURN NEXT a,b,c;
END;
$$ LANGUAGE plpgsql;
And running the previous code yields the following output:
ERROR: RETURN NEXT must specify a record or
row variable in function returning row
LINE 5: RETURN NEXT a,b,c;
^
Ok, this can't be done in this way either.
Fortunately, this is just a limitation of the PL/pgSQL language when creating the
RETURN value and not a PostgreSQL limitation. In the next chapter we see that,
for example, PL/Python can return complex data types in several ways without any
problems.
Returning with no predefined structure
Sometimes, you really do need to write a function where the return structure is un-
known. One nice thing about PostgreSQL function declarations is that you can use
the return type RECORD , which can be left undefined up to the moment the function
is called.
CREATE OR REPLACE FUNCTION run_a_query(query
TEXT)
RETURNS SETOF RECORD
AS $$
DECLARE
retval RECORD;
BEGIN
Search WWH ::




Custom Search