2

I am using Delphi 5 version and I want to connect to Oracle Database. I am having TDatabase component. I don't have any idea about how to connect to database through Delphi. Please provide the steps to connect database. thanks.

3 Answers 3

2

The TDatabase component is part of the BDE (Borland Database Engine), which is a deprecated technology, instead try using another alternatives which supports Oracle like ADO or Zeos. For an introduction to ADO check the Embarcadero Docs. Working with ADO Components and if you choose Zeos check the Official documentation.

Sign up to request clarification or add additional context in comments.

12 Comments

ADO components are the part of Delphi 5?
Zeos is dead slow for row retrieving: it retrieve the SELECT results one row at a time!!! And there are issues for BLOB > 2KB as far as I remember.
@RRUZ ADO is using OleDB to connect to Oracle. And both Oracle's and Microsoft's OleDB provider for Oracle are buggy with BLOB fields: the first returns NULL for 1/4 BLOB columns, and the second just do not handle BLOB and throw an exception. So I suspect ADO is not an option for Oracle.
@naren: You can use ADO with Delphi 5, without any problem. And even directly the OleDB layer if you wish.
In Delphi 5 era, I used BDE + SQL Links with Oracle and it did work well enough. Connecting to a recent Oracle DB may be a bet, anyway, although OCI shouldn't have changed much. IIRC in D5 ADO was only in the Enterprise SKU, not in the Professional.
|
2

That's funny, I've just finished (some minutes ago) the port of my Open Source native Oracle access to Delphi 5.

Here are the main features of this unit:

  • Direct access to the Oracle Call Interface (OCI) client, with no BDE, Midas, DBExpress, nor OleDB or ODBC provider necessary;
  • Dedicated to work with any version of the Oracle OCI interface, starting from revision 8;
  • Optimized for the latest features of Oracle 11g (e.g. using native Int64 for retrieving NUMBER fields with no decimal);
  • Able to work with the Oracle Instant Client for No Setup applications;
  • Natively Unicode (uses internal UTF-8 encoding), for all version of Delphi, with special handling of each database char-set;
  • Tried to achieve best performance available from every version of the Oracle client;
  • Designed to work under any version of Windows, either in 32 or 64 bit architecture;
  • Late-binding access to column names, using a new dedicated Variant type (similar to Ole Automation runtime properties);
  • Connections are multi-thread ready with low memory and CPU resource overhead;
  • Can use connection strings like '//host[:port]/[service_name]', avoiding use of the TNSNAME.ORA file;
  • Use Rows Array and BLOB fetching, for best performance (ZEOS/ZDBC did not handle this, for instance);
  • TQuery emulation class, for direct re-use with existing code, in replacement to the BDE;
  • Handle Prepared Statements - but by default, we rely on OCI-side statement cache, if available;
  • Native export to JSON methods, which will be the main entry point for our mORMot framework;
  • Compatible with Delphi 5 up to XE;
  • Since it doesn't use the DB unit, nor DBExpress or such other technologies, works with any edition of Delphi (even Delphi XE Stater or Delphi 7 Personal);
  • Open Source, released under a MPL/GPL/LGPL license.

See this web site for more details and feedback.

You have a TQuery like wrapper, to write code just like with the BDE.

Or you can write code as such:

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

Unfortunately, Delphi 5 do not allow late-binding via a variant, which is allowed with Delphi 6 and up:

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; 

If you really want to use the DB components in a RAD approach, take a look at the corresponding page in Torry's page:

  • ATOM Access To Oracle Magic;
  • DOCI Components for Direct Oracle Access;
  • NC OCI8;
  • Orange Component Set;
  • Vlad Karpov Native Link to Oracle.

You'll find there some old free components, mostly created at Oracle 8 time (SynDBOracle is optimized for Oracle 11g but will work with earlier versions of Oracle), but which may better suit your need for Oracle connection without the BDE.

Of course, there are also some very good commercial components around, still working with Delphi 5. But you'll have to pay the high price... and should better upgrade to a newer Delphi version, by the way. ;)

Comments

0

If you have the Enterprise version of Delphi 5 you can connecto to Oracle using the BDE and the Oracle SQL Link. That's the fastest way to use Oracle from D5. If you have the Professional version, you can use Oracle using the BDE through ODBC. The Enterprise version also should already have the ADO components, but in my tests then it was an inferior solution to the SQL Links, although if you have to port later to a newer Delphi release it is still supported while the BDE and the SQL Links are not.

The steps to connect are detailed in the help and the manuals.

10 Comments

hi i am using delphi 5 Professional version. I have BDE components.. but not getting how to connect to oracle through TDatabase. What steps i should follow? Whta shoul i mention in TDatabase properties?
With Delphi 5 Pro you can connect using TDatabase only via ODBC. You have first to setup an ODBC DSN, then you can set the proper parameters in the TDatabase Params property. You can also simply link it to the BDE database alias. Again, the procedure is well detailed in the manuals and help.
how to setup ODBC DSN? can u plz give me small example to how to cofigure?
Open "Data sources (ODBC)" in Administrative Tools and press the Help button. Also consult the Oracle ODBC driver documentation for its specific parameters. It looks you need to improve your basic knowledge about databases and their access technologies before continuing. Oracle is a very complex beast also, with a steep learning curve. I'd suggest you to spend some time documenting before attempting to setup the whole chain.
thanks for info.. i have not used the connection before so its getting difficult for me to understand.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.