You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 execute the following inside pgAdmin:
SELECT * FROM get_all();
FETCH ALL IN "<unnamed cursor 1>";
FETCH ALL IN "<unnamed cursor 2>";
it just works. Note - the unnamed cursors are updated on every run.
But when I do exactly the same in node-postgres, I'm getting this -
{ error: cursor "<unnamed portal 1>" does not exist
at Connection.parseE (D:\NodeJS\tests\node_modules\pg\lib\connection.js:546:11)
at Connection.parseMessage (D:\NodeJS\tests\node_modules\pg\lib\connection.js:371:19)
at Socket. (D:\NodeJS\tests\node_modules\pg\lib\connection.js:114:22)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:264:12)
at readableAddChunk (_stream_readable.js:251:11)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onread (net.js:587:20)
name: 'error',
length: 102,
severity: 'ERROR',
code: '34000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'portalcmds.c',
line: '168',
routine: 'PerformPortalFetch' }
The cursor definitely exists, and I'm executing it against the same connection.
Should it not be simpler, especially in the context of now supporting multiple results? One of the most important examples is to be able to return multiple cursors, i.e. when we now can concatenate several FETCH queries into one, execute it and presumably get all records from all the cursors fetched?
The text was updated successfully, but these errors were encountered:
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;
END
$BODY$ LANGUAGE plpgsql;
When I execute the following inside pgAdmin:
SELECT * FROM get_all();
FETCH ALL IN "<unnamed cursor 1>";
FETCH ALL IN "<unnamed cursor 2>";
it just works. Note - the unnamed cursors are updated on every run.
But when I do exactly the same in node-postgres, I'm getting this -
{ error: cursor "<unnamed portal 1>" does not exist
at Connection.parseE (D:\NodeJS\tests\node_modules\pg\lib\connection.js:546:11)
at Connection.parseMessage (D:\NodeJS\tests\node_modules\pg\lib\connection.js:371:19)
at Socket. (D:\NodeJS\tests\node_modules\pg\lib\connection.js:114:22)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:264:12)
at readableAddChunk (_stream_readable.js:251:11)
at Socket.Readable.push (_stream_readable.js:209:10)
at TCP.onread (net.js:587:20)
name: 'error',
length: 102,
severity: 'ERROR',
code: '34000',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'portalcmds.c',
line: '168',
routine: 'PerformPortalFetch' }
The cursor definitely exists, and I'm executing it against the same connection.
Why doesn't it work?
Do I really need the additional library to fetch the data?
Should it not be simpler, especially in the context of now supporting multiple results? One of the most important examples is to be able to return multiple cursors, i.e. when we now can concatenate several FETCH queries into one, execute it and presumably get all records from all the cursors fetched?
The text was updated successfully, but these errors were encountered: