Erasmo Aguilera
2016-04-20 19:36:53 UTC
Hello,
I've been looking around how to read results from a PL/pgSQL stored
function, but I've only found information about executing stored procedures
(not actually reading).
I have the following stored PL/pgSQL function that returns a single row from
a certain table:
CREATE OR REPLACE FUNCTION get_row(row_id my_table.id%TYPE)
RETURNS RECORD AS $$
DECLARE
result my_table%ROWTYPE;
BEGIN
SELECT * INTO result FROM my_table WHERE id = row_id;
RETURN result;
END;
$$ LANGUAGE plpgsql;
What is the correct SOCI code for reading the row returned by the previous
function? What if I need to return a TABLE instead of a RECORD?
Sincerely.
Erasmo Aguilera.
I've been looking around how to read results from a PL/pgSQL stored
function, but I've only found information about executing stored procedures
(not actually reading).
I have the following stored PL/pgSQL function that returns a single row from
a certain table:
CREATE OR REPLACE FUNCTION get_row(row_id my_table.id%TYPE)
RETURNS RECORD AS $$
DECLARE
result my_table%ROWTYPE;
BEGIN
SELECT * INTO result FROM my_table WHERE id = row_id;
RETURN result;
END;
$$ LANGUAGE plpgsql;
What is the correct SOCI code for reading the row returned by the previous
function? What if I need to return a TABLE instead of a RECORD?
Sincerely.
Erasmo Aguilera.