BDE vs ADO in Delphi

后端 未结 3 1711
一向
一向 2020-12-13 21:50

Please note the Edit below for a lot more information, and a possible solution

We recently modified a large Delphi application to use ADO connection

3条回答
  •  眼角桃花
    2020-12-13 22:11

    For best performance, should get a look at our Open Source direct access to Oracle.

    If you are processing a lot of TQuery, without using the DB components, we have a dedicated pseudo-class to use direct OCI connection, as such:

     Q := TQuery.Create(aSQLDBConnection);
     try
       Q.SQL.Clear; // optional
       Q.SQL.Add('select * from DOMAIN.TABLE');
       Q.SQL.Add('  WHERE ID_DETAIL=:detail;');
       Q.ParamByName('DETAIL').AsString := '123420020100000430015';
       Q.Open;
       Q.First;    // optional
       while not Q.Eof do begin
         assert(Q.FieldByName('id_detail').AsString='123420020100000430015');
         Q.Next;
       end;
       Q.Close;    // optional
     finally
       Q.Free;
     end;
    

    And I've added some unique access via a late-binding Variant, to write direct code as such:

    procedure Test(Props: TOleDBConnectionProperties; const aName: RawUTF8);
    var I: ISQLDBRows;
        Customer: Variant;
    begin
      I := Props.Execute('select * from Domain.Customers where Name=?',[aName],@Customer);
      while I.Step do
        writeln(Customer.Name,' ',Customer.FirstName,' ',Customer.Address);
    end;
    
    var Props: TOleDBConnectionProperties;
    begin
      Props := TSQLDBOracleConnectionProperties.Create(
        'TnsName','UserName','Password',CODEPAGE_US);
      try
        Test(Props,'Smith');
      finally
        Props.Free;
      end;
    end;
    

    Note that all OleDB providers are buggy for handling BLOBs: Microsoft's version just do not handle them, and Oracle's version will randomly return null for 1/4 of rows...

    On real database, I found out our direct OCI classes to be 2 to 5 times faster than the OleDB provider, without the need to install this provider. You can even use the Oracle Instant Client provided by Oracle which allows you to run your applications without installing the standard (huge) Oracle client or having an ORACLE_HOME. Just deliver the dll files in the same directory than your application, and it will work.

提交回复
热议问题