With the latest update of PostgreSQL supporting procedures. The official blog, quoted that \"As opposed to functions, procedures are not required to return a val
You can have INOUT
parameters in a procedure.
You call a procedure with the CALL statement; if there are any INOUT
parameters, the statement will return a result row just like SELECT
.
Here is an example that uses a procedure that returns a refcursor
:
CREATE PROCEDURE testproc(INOUT r refcursor) LANGUAGE plpgsql AS
$$BEGIN
r := 'cur';
OPEN r FOR VALUES (1), (42), (12321);
END;$$;
BEGIN;
CALL testproc(NULL);
r
-----
cur
(1 row)
FETCH ALL FROM cur;
column1
---------
1
42
12321
(3 rows)
COMMIT;
How about using the RAISE statement?
https://www.postgresql.org/docs/10/static/plpgsql-errors-and-messages.html