How to insert multiple rows in a single statement?
There are various approaches. For example, if you wish to insert these:
2 two
4 four
5 five
you can use UNIONs:
INSERT INTO table1 (col1, col2)
SELECT 2, 'two ' FROM RDB$DATABASE UNION ALL
SELECT 4, 'four' FROM RDB$DATABASE UNION ALL
SELECT 5, 'five' FROM RDB$DATABASE;
Please note that datatypes must match, esp. if you use Firebird 1.x. In the above example, 'four' and 'five' are varchar(4), while 'two' would evaluate to varchar(3) and you would get an error with Firebird 1.x. To work around this, you can use CAST or, in this case, add anoter space after the word: two, to make it 'two '.
You can also use EXECUTE BLOCK (with Firebird 2.0 and above):
set term ^ ;
EXECUTE BLOCK AS BEGIN
INSERT INTO table1 (col1, col2) VALUES (2, 'two');
INSERT INTO table1 (col1, col2) VALUES (4, 'four');
INSERT INTO table1 (col1, col2) VALUES (5, 'five');
END^
The Firebird FAQ