Is there a way to run multiple statements/transaction/a sql script ?
See original GitHub issueI know according to the protocol mysql only accept one statement a time.
But is there a way to work around it ? I tried
for(const q of script.split(';')) {
await pool.query(q);
}
It usually works until I encountered sth. like
delimiter $$
create procedure foo
begin
select........;
end $$
delimiter ;
So, do I really need to find a way to handle this ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Proper way to use a transaction around multiple inserts or ...
If you want to do rollback yourself, use try .. catch block. begin transaction begin try INSERT INTO TableA (id) VALUES (1) ...
Read more >Run Multi-Statement Transactions | CockroachDB Docs
The best way to run a multi-statement transaction from Java is to write a wrapper method that automatically handles transaction retry errors.
Read more >SQL statement sequential execution for multiple statments
After the execution of Query 1 is finished then the update query will be executed. You can run debugger to see the sequential...
Read more >Multiple Batches in a single Transaction | Brian F Love
The solution is to use the SET XACT_ABORT ON command. This instructs SQL Server to roll back the transaction when an error occurs...
Read more >Submitting Multiple SQL Statements in a Single Request
In the statement field, use a semicolon ( ; ) between each statement. In the parameters field, set the MULTI_STATEMENT_COUNT field to the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
no, they’ll be executed sequentially anyway. There might be a benefit of doing
OK I think i solved it. You need to terminate each line with a \r\n