Skip to content

Problems of <unnamed portal> using stored procedure returning REFCURSOR #2466

Closed
@floSeur

Description

@floSeur

Context

Hi, I'm currently trying to execute the code below using node-postgres

const config: QueryConfig = {
   text: 'select * from theriaque.get_drugs($1)',
   values: [`%${name}%`]
};
this._client.query(config)
   .then((res) => {
        console.log(res);
        console.log('QUERY >>>>>', `fetch all from "${res.rows[0]['get_drugs']}"`);
        this._client.query(`fetch all from "${res.rows[0]['get_drugs']}"`)
            .then((fetchedData) => {
                 console.log(fetchedData);
             })
             .catch((err) => {
                 console.log(err);
              });
     })
     .catch((err) => {
        console.log(err);
});
  • theriaque.get_drugs() is a stored procedure return a REFCURSOR
  • res.rows[0]['get_drugs'] is returning <unnamed portal 1>

Problem

When the second query is called to fecth data from the REFCURSOR unnamed portal 1, it goes to the catch and tells me that cursor "<unnamed portal 1>" does not exist.
I tried using pg-cursor but there is no result from the first query.

Any suggestions ?
Thanks

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