I'm trying to create a script that calls several stored procedures in PostgreSQL and print the result of some of them:
CREATE OR REPLACE FUNCTION script(
vtoken character varying)
RETURNS void AS
$BODY$
DECLARE
aux character varying;
BEGIN
PERFORM (SELECT acquire_table(vtoken));
-- This query gets the dynamically generated token for the client in that codebar
aux := (SELECT token
FROM clients c JOIN tables t ON c.tablekey = t.tablekey
WHERE codebar = vtoken);
PERFORM (SELECT order_drinks(aux, '{1}', '{1}'));
--EXECUTE (SELECT issue_ticket(aux));
PERFORM (SELECT order_drinks(aux, '{1}', '{1}'));
END;$BODY$
LANGUAGE plpgsql VOLATILE
The issue_ticket() function returns a multiple row result, I'd like to print it directly and continue execution of next function (order_drinks()). If I do PERFORM it does not show the results, and if I just try to execute the SELECT query as it is, it asks to assign return value to variable.