Index   Search   Add FAQ   Ask Question  
 

Please note: This page is not maintained anymore. Please visit the new and improved FAQ at http://www.orafaq.com/faq/oo4o

Oracle Objects for OLE (OO4O) FAQ

$Date: 08-Jun-2002 $
$Revision: 1.14 $
$Author: Frank Naudé $

Topics

  • What is Oracle Objects for OLE (OO4O)?
  • How does OO4O compare to ODBC?
  • Can one use OO4O to access Oracle data from Microsoft applications?
  • How does one install and configure OO4O?
  • What OO4O Objects are available for use while programming?
  • How does one connect to an Oracle Database?
  • How does one select data from an Oracle Database using OO4O?
  • How does one use bind variables in OO4O?
  • How does one execute DML and DDL statements using OO4O?
  • How does one call a stored procedure from OO4O?
  • How does one use the OraMetaData Object to describe tables?
  • Where can one get more info about OO4O?

  • Back to Oracle FAQ Index

    What is Oracle Objects for OLE?

    Oracle Objects for OLE (OO4O) is a middleware product manufactured by Oracle Corporation that allows native access (no ODBC) to Oracle databases from client applications via Microsoft OLE (Object Linking and Embedding) and COM.

    One can bind grids, text box widgets, and so on to OO4O via its own Data Control, one can also create dynasets, execute stored procedure code, or just about any other Oracle command one can think of. Oracle Objects consists of the following three components:

    OO4O's predecessor was called Oracle Glue.

  • Back to top of file

  • How does OO4O compare to ODBC?

    OO4O provides native access to Oracle and only Oracle databases, and is thus faster than ODBC access. ODBC is more generic and not database specific at all. One can use ODBC to connect to databases like Oracle, DB/2, SQLServer, etc. For more information about ODBC, read the ODBC FAQ.

    OO4O closely follows the ODBC query interface model, one can retain over 95% code compatibility between the OO4O and ODBC versions of data layer procedures. This translates to very short retooling times when porting between OO4O and ODBC.

  • Back to top of file

  • Can I use OO4O to access Oracle data from Microsoft applications?

    Yes, you can use OO4O from any Microsoft application that uses the VB-style macro language. This includes applications like:

  • Back to top of file

  • How does one install and configure OO4O?

    Follow these steps to install and configure OO4O:
    1. Install the Oracle Client CD on your workstation. This will install OO4O (Oracle Objects for OLE) and SQL*Net on your system.

    2. Configure SQL*Net and ensure you can tnsping and connect your Oracle database. This is done by adding an entry to the TNSNAMES.ORA file or by using utilities like the "Net Easy Configurator" to do it for you. See the SQL*Net FAQ for details.

    3. You are ready to GO!!!

  • Back to top of file

  • What OO4O Objects are available for use while programming?

    OO4O makes the following high-level Objects available for use:

  • Back to top of file

  • How does one connect to an Oracle Database?

    Connect to Oracle using the OpenDatabase function. The OpenDatabase function returns an OraDatabase object. Parameters are DB_NAME, CONNECT_DESCRIPTOR and CONNECT_OPTIONS. Look at the following Visual Basic code example:
    	Dim OraSession  As Object     'Declare variables as OLE Objects
    	Dim OraDatabase As Object
    	Dim OraDynaset  As Object
    
    	Set OraSession  = CreateObject("OracleInProcServer.XOraSession")
    	Set OraDatabase = OraSession.DbOpenDatabase("SQL*Net_Connect_String", "scott/tiger", 0&)
      
    	MsgBox "Connected to " & OraDatabase.Connect & "@" & OraDatabase.DatabaseName
    	MsgBox "OO4O Version:   " & OraSession.OIPVersionNumber 
    	MsgBox "Oracle Version: " & OraDatabase.RDBMSVersion
    

  • Back to top of file

  • How does one select data from an Oracle Database using OO4O?

    Use the OraDynaSet object to define recordsets. Look at this simple example:
    	Set OraSession = CreateObject("OracleInProcServer.XOraSession")
    	Set OraDatabase = OraSession.DbOpenDatabase("SQL*Net_Connect_String", "scott/tiger", 0&)
    	Set OraDynaset = OraDatabase.DbCreateDynaset("select empno, ename from emp", 0&)
    	MsgBox "Employee " & OraDynaset.Fields("empno").value & ", #" & OraDynaset.Fields("ename").value
    
    One can also loop through the result set using code like this:
    	Do While(OraDynaset.EOF = FALSE)
    	   Response.write(OraDynaset.Fields("TNAME") & "<BR>")
    	   osRecordSet.MoveNext
    	Loop

  • Back to top of file

  • How does one use bind variables in OO4O?

    Use the "OraParameters.Add Name, Value, IOType" method to substitute bind variables with values before executing a statement. If you don't, you will get error "not all variables bound". The IOType filed can be one of the following: Look at this example:
    	sqlStmt = "SELECT tname FROM tab WHERE tname LIKE :var1"
    	OraDatabase.Parameters.add "var1", "%A%", 1   ' Substitute Name=Value of type ORAPARM_INPUT
    	Set osRecordSet = OraDatabase.DbCreateDynaset(sqlStmt, cint(0))  
    	Do While(osRecordset.EOF = FALSE)
    	   ' Use data: osRecordset.Fields("TNAME") in this example...
    	   osRecordSet.MoveNext
    	Loop
    

  • Back to top of file

  • How does one execute DML and DDL statements using OO4O?

    One can use any valid DDL and DML statement with the ExecuteSQL (or DBExecuteSQL) method. Look at this example:
    	rowcount = OraDatabase.ExecuteSQL("create table X (A date)")
    	rowcount = OraDatabase.ExecuteSQL("insert into X values (sysdate)")
    	OraSession.CommitTrans    ' or OraSession.Rollback
    

  • Back to top of file

  • How does one call a stored procedure from OO4O?

    A stored procedure block can be executed from the CreateSQL or ExecuteSQL methods. OO4O supports the SQL statement objects for PL/SQL stored procedures. Look at this VB example:
    	sql1 = "begin test_sproc(param2=>'two_b', param1=>'one_b'); end;"
    	rowcnt = OraDatabase.DbExecuteSQL(sql1)   
    
    More complex example using input and output parameters. Note that the output parameter returns a cursor:
    	OraDatabase.Parameters.Add "NAME", "SUPERSPORT", ORAPARM_INPUT
    	OraDatabase.Parameters("NAME").ServerType = ORATYPE_VARCHAR2
    
    	OraDatabase.Parameters.Add "ORDCURSOR", 0, ORAPARM_OUTPUT
    	OraDatabase.Parameters("ORDCURSOR").ServerType = ORATYPE_CURSOR
    
    	Set OraSQLStmt = OraDatabase.CreateSql("begin CUSTOMERS.GetCutomerSalesOrder(:Name,:OrdCursor);end;", ORASQL_FAILEXEC)
    
    	Set OrderDynaset = OraDatabase.Parameters("ORDCURSOR").Value
    	'Now display the Dynaset's field value
    	MsgBox "Order Details are " & OrderDynaset.fields("ordid").Value & " " & 
    

  • Back to top of file

  • How does one use the OraMetaData Object to describe tables?

    The OraMetaData object (available from Oracle8i) can be used to retrieve all sorts of information about an Oracle schema. For example, one can list all objects in a schema, all columns of a table, etc. Look at this simple ASP example:
    	Response.write("<H1>Describe Table EMP:</H1>")
    	Set objOraMetaData    = OraDatabase.Describe("EMP") 
    	Set objOraMDAttribute = objOraMetaData("ColumnList")
    	Set objColumnList     = objOraMDAttribute.Value
    	 
    	For iColCount = 0 To objColumnList.Count - 1 
    	    Set objColumnDetails = objColumnList(iColCount).Value 
    	    Response.Write "<P >Column: "    & objColumnDetails("Name") & _ 
    	                   "<BR>Type:   "    & objColumnDetails("DataType") & _ 
    	                   "<BR>Size:   "    &  objColumnDetails("DataSize") & _ 
    	                   "<BR>IsNull: "    & objColumnDetails("IsNull") & _ 
    	                   "<BR>Precision: " & objColumnDetails("Precision") & _ 
    	                   "<BR>Scale: "     & objColumnDetails("Scale")
    	Next
    

  • Back to top of file

  • Where can one get more info about OO4O?

  • Back to top of file
  • HOME | ASK QUESTION | ADD FAQ | SEARCH | E-MAIL US