使用.net提供程序将firebird嵌入多个插件 [英] firebird embedded multiple inserts using .net provider

查看:99
本文介绍了使用.net提供程序将firebird嵌入多个插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个将使用firebird嵌入式和/或postgres的应用程序,具体取决于用户的复杂程度.火鸟嵌入式的观点是应该减少安装,防火墙,UAC等问题.到目前为止,postgres就像在云上行走,但是我遇到了火鸟的障碍.该应用程序是.net,我正在使用此提供程序 http://www.firebirdsql.org/zh/net-provider/版本3.0.2

I am developing an application that will use firebird embedded and/or postgres depending on user sophistication. The argument for firebird embedded is that there should be less installation, firewall, UAC, etc issues. So far postgres is like walking on clouds but I have hit a roadblock with firebird. The app is .net and I am using this provider http://www.firebirdsql.org/en/net-provider/ version 3.0.2

从技术上讲一切正常,但是嵌入了firebird,我每秒只能插入约100条记录,而使用postgres时,每秒可以插入3000条以上!使用postgres,我将大量INSERT INTO ...语句作为一个命令启动,这很好.对于火鸟来说,进展并不顺利.这是起作用的(缓慢的)

Everything technically works but with firebird embedded I am inserting only around 100 records per second whereas with postgres it's over 3000 per second! With postgres I launch a large amount of INSERT INTO... statements as one command and it's fine. For firebird it's not going well. Here is what does work (slowly)

String query = @"INSERT INTO Customers(ID, Name, SiteID) VALUES(1,'delta',2);
INSERT INTO Customers(ID, Name, SiteID) VALUES(2,'phoenix',2);
";
FbScript fbs = new FbScript(query);
fbs.Parse();
FbConnection fbc = new FbConnection(ConnectionString);

FbBatchExecution fbe = new FbBatchExecution(fbc, fbs);
fbe.Execute(true);

但是,我正在尝试不进行解析.类似于第二个答案,这里对firebird数据库运行多个插入查询使用isql 或此处 http://www.firebirdfaq.org/faq336/

However, I am trying to do without the parse. Something similar to the second answer here Run multiple insert queries against firebird database using isql or here http://www.firebirdfaq.org/faq336/

String sql = @"set term ^ ;
EXECUTE BLOCK AS BEGIN
INSERT INTO Customers(ID, Name, SiteID) VALUES(1,'delta',2);
INSERT INTO Customers(ID, Name, SiteID) VALUES(2,'phoenix',2);
end^";

FbCommand cmd = new FbCommand();            
PrepareCommand(cmd, connection, (FbTransaction)null, CommandType.Text, sql, commandParameters, out mustCloseConnection);
cmd.ExecuteNonQuery();

有了这个,我得到了例外

With this I get the exception

Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 5
term

第一种方法是唯一的方法吗?太慢了:(

Is the first way the only way? It's so slow :(

推荐答案

您不需要set term语句,它们是isql

You don't need the set term statements, these are isql specific thing. So try

String sql = @"EXECUTE BLOCK AS BEGIN
INSERT INTO Customers(ID, Name, SiteID) VALUES(1,'delta',2);
INSERT INTO Customers(ID, Name, SiteID) VALUES(2,'phoenix',2);
END";

这篇关于使用.net提供程序将firebird嵌入多个插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆