Skip to content

Multiple queries in parametized query #1400

Closed
@officer-rosmarino

Description

@officer-rosmarino

If I run the following code

query = `
  INSERT INTO test_table (id, name, age) VALUES ($1, $2, $3);
  UPDATE test_table SET name='Alice' WHERE id=1`;
params = [2, 'Bob', 78];

 client.query(query, query_params)
  .then(() => {
    client.release();
    console.log('ok'); 
  }).catch(err => {
    client.release();
    console.log(err.message);
  });

I end up getting the following cannot insert multiple commands into a prepared statement.

Why is it like this? What are the reasons?
I think it would be really useful to be able to run multiple commands in the same prepared statement, in order to be able to run a single query with many ( N) commands, instead of N different queries with 1 single command.

I'd like to open up a discussion about this, if it has not been discussed before.

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