Subject Re: [IBO] no wait stored procedure?
Author Robert Martin
Hi

My understanding is that FB does not support multiple threads on one connection, i.e. the fbClient.dll library was not thread safe.  The work around for this is to simply create a new connection, within the new thread.  This is what my suggestion is.  My understanding is FB 3 will support multiple threads on a single DB connection.

Here is how I usually do it to get you started.   p.s. this is just an example not real code...


Put all IBO component creation / releasing code within the .execute procedure of the thread.  I often pass connection details into the threads constructor method  (fConnecionDetail has this detail).

sample TThread.execute method....


        Session                       := TIB_Session.Create(Nil);
        Session.UseCursor     := False;

        IBODataBase := TIBODatabase.Create(Session);
        IBODataBase.IB_Session      := Session;
        IBODataBase.Path                 := fConnecionDetail.DBPath;
        IBODataBase.SchemaCacheDir  := fConnecionDetail.SchemaCacheDir
        IBODataBase.Server          := fConnecionDetail.Server;
        IBODataBase.Password        := fConnecionDetail.Server;
        IBODataBase.Username        := fConnecionDetail.UserName;
        IBODataBase.Protocol        := cpTCP_IP;
        IBODataBase.Connected       := True;

    Transaction            := TIB_Transaction.CreateForSession(fIBODataBase, fIBODataBase.IB_Session);
    Transaction.Isolation  := tiCommitted;
    Transaction.AutoCommit := False;

        aQuery := TIBOQuery.Create(Session);
        aQuery.IB_Session := Session;
        aQuery.ib_Connecion := IBODatabase;
       aQuery.IB_Transaction := Transaction;
       try
.....
     finally
     


     end


Cheers
Rob



On 9/06/2014 5:03 p.m., russell@... [IBObjects] wrote:
Thanks Jason and Rob for comments. I will try making a new thread in my program which runs a procedure in the DB. I am doing this now in the program's main thread. 

I will use a separate connection, transaction and tib_dsql component. I cannot say why I must or should have these separate so would welcome an explanation. 

By not using isql in a scheduled bat file execution I will keep all maintenance tasks internal to the program.

Russell

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2014.0.4592 / Virus Database: 3955/7644 - Release Date: 06/08/14