I have a PostgresQL function that returns multiple result sets. I can extract these results in .net without problems (so that I know that my function works correctly), but I am having problems with node-postgres.
The result object returns an array of 7 elements, which corresponds to the number of returned data sets.
In Node, each of the 7 lines simply contains a line <unnamed portal 1>.
connection.query("BEGIN");
connection.query({text: "SELECT getoperationaldatasetmodel($1)", values : [clientid]}, function(err, results) {
if (err) {
connection.query("COMMIT");
self.pool.release(connection);
callback(err);
}
else {
var opsDataset = null;
var rows = results.rows;
}
So: does node-postgres support multiple result sets, and if so, any suggestions on how to extract it?
EDIT: Here is the code I used with node-postgres if anyone else should use it in the future.
connection.query("BEGIN");
connection.query({text: "SELECT myfunction($1)", values : [clientid]}, function(err, results) {
if (err) {
connection.query("COMMIT;");
}
else {
connection.query('FETCH ALL FROM "<unnamed portal 1>"', function(err, r1) {
});
connection.query('FETCH ALL FROM "<unnamed portal 2>"', function(err, r2) {
});
});
source
share