Firebird Execute Statement

流过昼夜 提交于 2019-12-13 01:18:26

问题


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"

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();

I was trying to replicate the example on the firebird website here.

I am using firebird version 2.5.2 and Firebird ADO.NET Data provider 4.1.5.0


回答1:


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".

So create just your execute block statement and you're fine.




回答2:


you don't have to use set term ^;

just end your code with ^

if you DO HAVE TO set term to ^, put it back with set term ;^



来源:https://stackoverflow.com/questions/23837893/firebird-execute-statement

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!