Elias
Elias

Reputation: 1427

Firebird Execute Statement

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

Upvotes: 1

Views: 1868

Answers (2)

dhiasa janwar aji
dhiasa janwar aji

Reputation: 1

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

Upvotes: 0

cincura.net
cincura.net

Reputation: 4150

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.

Upvotes: 2

Related Questions