Your query does not conform to the Firebird syntax. Drivers can only execute a single statement at a time (be aware that an EXECUTE BLOCK
is considered to be a single statement).
You should not use SET TERM
, that is an artifact of the ISQL tool (and some other query tools like FlameRobin) and is not actually part of the Firebird SQL language.
Nor should you include ;
in a query. Those are only valid in 1) PSQL (stored procedures, triggers and inside EXECUTE BLOCK
) and 2) once again in tools like ISQL to separate (end) statements.
So using the following query on its own should be sufficient:
INSERT INTO COUNTRY1 SELECT '2', 'two ' FROM RDB$DATABASE UNION ALL SELECT '4', 'four' FROM RDB$DATABASE UNION ALL SELECT '5', 'five' FROM RDB$DATABASE
EDIT
As I commented, maybe the parser doesn't understand UNION
when combined with an INSERT ... SELECT
.
Using a sub-select will probably work:
INSERT INTO COUNTRY1
SELECT column1, column2 FROM (
SELECT '2' AS column1, 'two ' AS column2 FROM RDB$DATABASE
UNION ALL SELECT '4', 'four' FROM RDB$DATABASE
UNION ALL SELECT '5', 'five' FROM RDB$DATABASE
)
EDIT 2
I just tested it with the the code below and it works: the expected rows are inserted:
static void Main(string[] args)
{
var constrBuilder = new FbConnectionStringBuilder();
constrBuilder.DataSource = "localhost";
constrBuilder.Database = @"D:\data\db\testdatabase.fdb";
constrBuilder.UserID = "sysdba";
constrBuilder.Password = "masterkey";
string constr = constrBuilder.ToString();
using (var con = new FbConnection(constr))
{
con.Open();
using (var trans = con.BeginTransaction())
{
var cmd = new FbCommand();
cmd.CommandText = "INSERT INTO COUNTRY1 SELECT '2', 'two ' FROM RDB$DATABASE UNION ALL SELECT '4', 'four' FROM RDB$DATABASE UNION ALL SELECT '5', 'five' FROM RDB$DATABASE";
cmd.Connection = con;
cmd.Transaction = trans;
cmd.ExecuteNonQuery();
trans.Commit();
}
}
}