⌘BABAKOV.NET Let's code!
100% [dark] [ru]

How to Insert Multiple Rows in InterBase with One Script

I've been interested in this question for a long time! How can I do it? Insert multiple rows into a table with one query. The thing is that in the InterBase DBMS, unlike many other DBMS, a query of the type:

insert into tabble1
    (param1, param2)
         values
             (1, \'Сидоров\'), (2, \'Петров\'), (3, \'Иванов\');

cannot be executed.

I don't know why, but it's not possible. It doesn't work like that.
But it's very tempting!!!
Because inserting multiple records at once is much faster and saves time.

But there is an alternative!

Here's how it's done:

execute block as begin 
insert into tabble1 (param1, param2) values (1, \'Сидоров\');
insert into tabble1 (param1, param2) values (2, \'Иванов\');
insert into tabble1 (param1, param2) values (3, \'Петров\');
end

This is all sent to the server as one query.

It has been found that there is a significant acceleration in data insertion when using this mechanism.

Comments (0)

No comments yet.

Leave a comment
Comment
Images (up to 5 MB)
Your comment will appear after moderation.