火鸟执行语句 [英] Firebird Execute Statement
问题描述
我正在尝试通过使用execute块将多行插入到firebird表中.但是我收到一个错误消息,说条件"无效.
I am trying to insert multiple rows into a firebird table by using an execute block. But I get an error saying that "term" is invalid.
"Dynamic SQL Error nSQL error code = -104 Token unknown - line 1, column 5 term"
这是我用于插入的C#代码
Here is the C# code that I use for the insert
connection.Open();
string insertData = "set term ^ ; execute block as begin;";
foreach (dataPoint dataPointInsert in dataPointList)
{
insertData += string.Format(" insert into data (trip_id, trip_type, longitude, latitude, speed, date_time, heading, valid) values ('{0}','{1}','{2}','{3}',{4},'{5}','{6}',{7});",
dataPointInsert.GUID, dataPointInsert.tripType, dataPointInsert.longitude, dataPointInsert.latitude, dataPointInsert.speed, dataPointInsert.dateTime, dataPointInsert.heading, Convert.ToInt32(dataPointInsert.valid));
}
insertData += " end^";
var createCommand = new FbCommand(insertData, connection);
createCommand.ExecuteNonQuery();
我试图在firebird网站此处上复制该示例.
I was trying to replicate the example on the firebird website here.
我正在使用Firebird 2.5.2版和Firebird ADO.NET数据提供程序4.1.5.0
I am using firebird version 2.5.2 and Firebird ADO.NET Data provider 4.1.5.0
推荐答案
您不必(实际上,您不应该这样做,因为它是客户端命令,Firebird无法理解),因此您必须使用set term
,因为FbCommand
和Firebird本身(在协议中)只能在批处理"中执行一个查询.
You don't (in fact you shouldn't, because it's a client side command, Firebird doesn't understand it) have to use set term
because FbCommand
and Firebird itself (in protocol) can execute only one query in a "batch".
因此,创建 just 您的execute block
语句就可以了.
So create just your execute block
statement and you're fine.
这篇关于火鸟执行语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!