IBSql:=TIBSql.Create(self.DB);
IBSql.database:=self.DB;
IBSql.transaction:=IBSql.database.DefaultTransaction;
IBSql.transaction.StartTransaction;
try
IBSql.Sql.add('insert into persons values (1,"person1");');
IBSql.Sql.add('insert into persons values (2,"person2");');
IBSql.Sql.add('insert into persons values (3,"person3");');
IBSql.ExecQuery; //exception happens here
IBSql.transaction.Commit;
finally
IBSql.Free;
end;
I have following code
IBSql:=TIBSql.Create(self.DB);
IBSql.database:=self.DB;
IBSql.transaction:=IBSql.database.DefaultTransaction;
IBSql.transaction.StartTransaction;
try
IBSql.Sql.add('insert into persons values (1,"person1");');
IBSql.Sql.add('insert into persons values (2,"person2");');
IBSql.Sql.add('insert into persons values (3,"person3");');
IBSql.transaction.Commit; //exception happens here
finally
IBSql.Free;
end;
If add only one SQL add time to IBSQL component then everything works fine
but if i put more than SQL clause at the once then exception is raised.
Could anyone give a help or tell the reason why it is so?
I appreciate your answers!
> Sorry one line was missed
>
> IBSql:=TIBSql.Create(self.DB);
>
> IBSql.database:=self.DB;
> IBSql.transaction:=IBSql.database.DefaultTransaction;
> IBSql.transaction.StartTransaction;
> try
> IBSql.Sql.add('insert into persons values (1,"person1");');
> IBSql.Sql.add('insert into persons values (2,"person2");');
> IBSql.Sql.add('insert into persons values (3,"person3");');
> IBSql.ExecQuery; //exception happens here
> IBSql.transaction.Commit;
> finally
> IBSql.Free;
> end;
You can only use one statement in TIBSQL at a time.
you need to use TIBScript for what you are doing.
Or you could modify your code as follows :
IBSql.database:=self.DB;
IBSql.transaction:=IBSql.database.DefaultTransaction;
IBSql.transaction.StartTransaction;
try
IBSql.Sql.clear ;
IBSql.Sql.add('insert into persons values (1,"person1");');
IBSql.ExecQuery;
IBSql.Sql.clear ;
IBSql.Sql.add('insert into persons values (2,"person2");');
IBSql.ExecQuery;
IBSql.Sql.clear ;
IBSql.Sql.add('insert into persons values (3,"person3");');
IBSql.ExecQuery; //exception happens here
IBSql.transaction.Commit;
finally
IBSql.Free;
end;
Regards Will
I use delphi5 and I can't find any component TIBScript.
Do you know where I can can find it?
-Craig
--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://delphi.weblogs.com
InterBase Perf. Monitor : http://delphi.weblogs.com/IBPerformanceMonitor
InterBase PLANalyzer 1.1: http://delphi.weblogs.com/IBPLANalyzer
By the way which supposed to be faster?
TIBQuery or TIBSQL like how Will Honor demostrated in his reply?
Short test i made was that performance was almost same with over 10000
sql clauses.
> Thanks a lot! That was the reason why i didn't find TIBQuery component.
Do you mean TIBScript or TIBQuery?
>
> By the way which supposed to be faster?
> TIBQuery or TIBSQL like how Will Honor demostrated in his reply?
>
> Short test i made was that performance was almost same with over 10000
> sql clauses.
I believe that all methods should be about the same. They all use a
TIBSQL to actually run the SQL.
Regards Will.
> I believe that all methods should be about the same. They all use a
> TIBSQL to actually run the SQL.
Do you know any other ways to get the performance to little bit better of
faster?
Now when i executing something like 10000 SQL queries it takes around 60
seconds?
Use a stored procedure to do the insert statements.
(already prepared, less network traffic)
Commit every 1000 records.
(as the transaction gets larger it slows down.
No, you still have to prepare the SP itself. One Prepare for
an IBSQL and 1 Prepare for an IBStoredProc per execution of hte
SP. Network traffic is lighter for IBSQL.
All an SP has over a straight SQL statement is the ms's it
takes to compile the statement once in IBSQL but is already
compiled in the SP. Of course you have to compile the SP
executing statement anyways so even there there is no
performance gain (actually a loss since IBStoredProc unprepares
itself after each execution so has to be prepared again for hte
next execution).
>Commit every 1000 records.
>(as the transaction gets larger it slows down.
IBSQL holds its prepare over hte lifetime of the component, IBStoredProc will actually prepare every statement each time.
--
Jeff Overcash (TeamB)