Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Reading a cursor from name #34

@vitaly-t

Description

@vitaly-t

Following this issue: brianc/node-postgres#1476


I have two tables: users + products, and I have a function that returns two cursors for those:

CREATE or replace FUNCTION get_all() RETURNS SETOF refcursor AS
$BODY$
DECLARE
    u refcursor;
    p refcursor;
BEGIN
    OPEN u FOR
    SELECT * FROM users;
    RETURN NEXT u;

    OPEN p FOR
    SELECT * FROM products;
    RETURN NEXT p;
END
$BODY$ LANGUAGE plpgsql;

When I query SELECT * FROM get_all(), I am getting the following data back:

[ anonymous { get_all: '<unnamed portal 1>' },
  anonymous { get_all: '<unnamed portal 2>' } ]

How can I initiate a cursor read from the cursor names, using this library?


Please note that when I am executing the following in pgAdmin:

SELECT * FROM get_all();
FETCH ALL IN "<unnamed cursor 1>";
FETCH ALL IN "<unnamed cursor 2>";

I am getting all the data correctly for the 2 tables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions