question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to execute multiple queries in one run?

See original GitHub issue

I’m facing a problem that I would like to execute multiple queries separated by ‘;’ by a single exec, is that possible?

My test code which is failing looks like:

      var query = '' +
        'UPDATE "records_raw" ' +
        'SET "title" = ? ' +
        'WHERE "id" = ?' +
        ';' +
        'UPDATE "records_raw" ' +
        'SET "title" = ? ' +
        'WHERE "id" = ?' +
        ';';

      var bindings = [
        "x", "1",
        "y", "2"
      ];

      knex.raw(query, bindings).exec(function(err, result) {
        assert.isNotError(err);
      });

The error:

Error(cannot insert multiple commands into a prepared statement, ...

Is there a way to disable prepared statements for such queries?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:9
  • Comments:40 (20 by maintainers)

github_iconTop GitHub Comments

29reactions
Sequoya42commented, Jan 27, 2017

Any update ? Is it possible now to make multiQuery? If so, using what syntax?

12reactions
josephfinlaysoncommented, Nov 6, 2014

Isn’t this possible by just marking

    multipleStatements: true

in the connection block of one’s configuration: e.g.

    connection: {
        host: 'localhost',
        user: 'superSecret',
        password: 'notGonnaTell',
         port: 8889,
        database: 'babelverse_core',
        multipleStatements: true
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run multiple SQL queries? - Stack Overflow
Simply put three queries one after the other in a .sql file, with semi-colons after each statement, ...
Read more >
Including multiple SQL statements in one query - IBM
To run a query with multiple statements, ensure that each statement is separated by a semicolon; then set the DSQEC_RUN_MQ global variable to...
Read more >
Use a union query to combine multiple queries into a single ...
On the Create tab, in the Queries group, click Query Design. · On the Design tab, in the Query group, click Union. ·...
Read more >
Running multiple queries at the same time. - SQL Studies
One way to do it would be to open multiple query windows, and run them all as close to at the same time...
Read more >
I want to execute multiple SQL statements in one console at ...
Yes, just select multiple queries and execute them. +++++++++= To control execution behavior go to settings. In general statements ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found