Hi,
I am trying to insert 1000000 records to firebird with this code but i got error "undeffined message number".
static void FirebirdInsert(int iter)
{
using (FbTransaction trans = _fbcon.BeginTransaction())
{
using (FbCommand cmd = _fbcon.CreateCommand())
{
byte[] value = File.ReadAllBytes(@"nnn.jpg");
cmd.Transaction = trans;
cmd.CommandText = "execute block as declare"
+" i int = 0;"
+"begin"
+"while (i <"+ iter +") do"
+"begin"
+"insert into t2"
+"(MBR, FIR, IME, PRZ, VRE, B) values"
+"(null,6156830,'Goran','Vidak',current_timestamp,@b);"
+"i = i + 1;"
+"end"
+"end";
cmd.Parameters.Add("b", FbDbType.Binary, value.Length).Value = value;
cmd.ExecuteNonQuery();
trans.Commit();
}
_fbcon.Close();
}
}
I dont know if maybe i cannot use parameter (which is blob type) in execute block this way. I also try instead of execute block (also in transaction) and that worked but very slow, about 8
inserts/sec. Command as execute block for simplier excample worked about 100x faster for me than
transaction with for loop. Any suggestion? Thanks in advance.
FbCommand cmd = new FbCommand("insert into t2"
+"(MBR, FIR, IME, PRZ, VRE, B) values"
+"(null,6156830,'Goran','Vidak',current_timestamp,@b);",_fbcon );
for (int i = 0; i < iter; i++)
{
cmd.Parameters.Add("b", FbDbType.Binary,value.Length).Value = value;
cmd.ExecuteNonQuery();
}