Compiler Options

First of all you have to set some compiler options depending which type of application you are writing and which database you are using.
Edit the "JvUIB.inc" file in the source directory with a text editor and uncomment compiler options you need.

Database.

Borland Interbase

Filrebird

Yaffil

Multithreading and N-Tiers servers application.

You have 2 choices:

Sharing one DB connection with all threads, in this case 2 threads can share the same Database connection or the same Transaction safely without freezing the server. Some examples of server applications are: Web server, CORBA, DCOM, or Delphi ORB provided provided with UIB. For an example of Multithread server try the the sample applications in the "ClentServer" directory. You must set this compiler option: {$DEFINE UIBTHREADSAFE} excepting with Interbase 7 (The library is allready ThreadSafe)

Create one DB Connection per Thread, in this case you should desactivate {$DEFINE UIBTHREADSAFE}, and setting your DB connection to use the remote protocol (excepting with Interbase 7), to have all threads working faster.

Borland C++ Builder 6

You can choose to use original Interbase header files (IBase.h & IBError.h) in this case uncomment {$DEFINE USE_IBERROR_H} & {$DEFINE USE_IBASE_H}.

Dynamic & Static Linking library.

{$DEFINE INTERBASE_DYNAMIC_LINK}is the default option to load Interbase library only when needed.

Language

Contact me to add your language.

Transaction Rules

Définitions:

Rules

  1. Transactions are started automaticaly when a Query is Open.
  2. Transactions stay alive until all attached queries are closed.
  3. Transaction rollbacked automatically on internal error (open, ExecSQL, next ...).
  4. Transaction commited automatically if a query component is destroyed or detached from transaction.

Example

procedure TForm1.BtOpenClick(Sender: TObject);
var
  Transaction: TJvUIBTransaction;
  Query1: TJvUIBQuery;
  Query2: TJvUIBQuery;
begin
  Transaction := TJvUIBTransaction.Create(nil);
  Query1 := TJvUIBQuery.Create(nil);
  Query2 := TJvUIBQuery.Create(nil);
  try
    Transaction.DataBase := DataBase;
    Query1.Transaction := Transaction;
    Query2.Transaction := Transaction;
    try
      Query1.SQL.Text := 'SELECT * FROM MYTABLE1;
      Query1.Open; // transaction started (Rule 1)
      while not Query1.Eof do
      begin
        // ...
        Query1.Next;
      end;
      Query1.Close; // Stay in transaction (default action)

      Query2.SQL.Text := 'SELECT * FROM MYTABLE2';
      Query2.Open; // transaction not started because Query1 have not closed the Transaction.
                   // On error the transaction is automatically rollbacked(Rule 3)
      
      while not Query1.Eof do
      begin
        // ...
        Query2.Next;
      end;
      Query2.Close(etmCommit); // Transaction Commited because Query1 is closed
                               // if Query1 not closed then CommitRetaining(Rule 2)


    except
      Transaction.RollBack; // on error transaction rollbacked
      // ...
       
    end;
  finally
    Query1.Free; // if transaction active then close & commit(Rule 4)
    Query2.Free; // if transaction active then close & commit(Rule 4)
    Transaction.Free;
  end;
end;

 

Using TJvUIBQuery 

There is 3 methods to use this component.