1
votes

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

2
No I haven't. Do you think the newlines in the command are necessary? - Elias
Looks like it's a duplicate of this stackoverflow.com/questions/16293135/… - Graymatter
@Graymatter it isn't: set term simply is not part off the firebird syntax (it does exist in client tools like isql) - Mark Rotteveel

2 Answers

2
votes

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.

0
votes

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 ;^