PK
?Aoa, mimetypeapplication/epub+zipPK ?A iTunesMetadata.plisth
Applies To
Description
Returns a copy of the OraTimeStamp
object that has the date-time value normalized to the session time zone of the current OraTimeStampTZ
object.
Usage
Set OraTimeStampObj = OraTimeStampTZObj.ToOraTimeStampLTZ
Remarks
Returns a new OraTimeStamp
object that has the date-time values normalized to the session time zone of the current OraTimeStampTZ
object.
Examples
Dim OraTimeStampTZ As OraTimeStampTZ ... 'Create OraTimeStampTZ using a string Set OraTimeStampTZ = OraSession.CreateOraTimeStampTZ("2003-APR-29" & _ "12:00:00 -07:00", "YYYY-MON-DD HH:MI:SS TZH:TZM") 'Assuming that the Session Time Zone is "-08:00" 'returns a new OraTimeStamp object with date value normalized to 'session Time Zone, "2003-APR-29 11:00:00" Set OraTimeStamp = OraTimeStampTZ.ToOraTimeStampLTZ ...
Applies To
Description
Returns the clone of an OraObject
or OraRef
object.
Usage
Set OraObjectClone = OraObject.CloneSet OraRefClone = OraRef.Clone
Remarks
This method makes a copy of a Value
instance or REF
value and returns an OraObject
or OraRef
object associated with that copy. This copy does not change due to a dynaset move operation or OraSQLStmt
refresh operation. An OraObject
object returned by this method allows an operation to access its attribute values of an underlying value instance and disallows any operation to modify its attribute values.
Examples
Before running the sample code, make sure that you have the necessary data types and tables in the database. For the following examples, see "Schema Objects Used in the OraObject and OraRef Examples"
Example: Clone Method for the OraObject Object
The following example shows the use of the Clone
method.
Dim OraSession as OraSession Dim OraDatabase as OraDatabase Dim OraDynaset as OraDynaset Dim Address as OraObject Dim AddressClone as OraObject 'Create the OraSession Object. Set OraSession = CreateObject("OracleInProcServer.XOraSession") 'Create the OraDatabase Object by opening a connection to Oracle. Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&) 'create a dynaset object from person_tab set OraDynaset = OraDatabase.CreateDynaset("select * from person_tab",0&) 'retrieve a address column from person_tab. Here Value property of OraField object 'returns Address OraObject set Address = OraDynaset.Fields("Addr").Value 'here Address OraObject points to Address value instance in the server 'for the first row msgbox Address.Street 'move to second row OraDynaset.MoveNext 'here Address OraObject points to Address value instance in the server 'for the second row msgbox Address.Street 'get the clone of Address object. This clone points to the copy of 'the value instance for second row set AddressClone = Address.Clone 'move to third row OraDynaset.MoveNext 'here Address OraObject points to Address value instance in the server 'for third row msgbox Address.Street 'here AddressClone OraObject points to copy of Address value instance ' in the server for second row msgbox AddressClone.Street
Example: Clone Method for the OraRef Object
The following example shows the usage of the Clone
method. Before running the sample code, make sure that you have the necessary data types and tables in the database.
Dim OraSession as OraSession Dim OraDatabase as OraDatabase Dim OraDynaset as OraDynaset Dim Person as OraRef Dim PersonClone as OraRef 'Create the OraSession Object. Set OraSession = CreateObject("OracleInProcServer.XOraSession") 'Create the OraDatabase Object by opening a connection to Oracle. Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&) 'create a dynaset object from customers set OraDynaset = OraDatabase.CreateDynaset("select * from customers", 0&) 'retrieve a aperson column from customers. 'Here Value property of OraField object 'returns Person OraRef set Person = OraDynaset.Fields("aperson").Value 'here Person OraRef points to Person Ref value in the server for the first row msgbox Person.Name 'move to second row OraDynaset.MoveNext 'here Person OraRef points to Person Ref value in the server for the second row msgbox Person.Name 'get the clone of Person object. 'This clone points to the copy of the Ref for second row set PersonClone = Person.Clone 'move to third row OraDynaset.MoveNext 'here Person OraRef points to Person Ref value 'in the server for the third row msgbox Person.Name 'here PersonClone OraRef points to Person Ref value 'in the server for the second row msgbox PersonClone.Name
Applies To
Description
Determine whether the changes made to fields (columns) are immediately reflected in the local mirror by retrieving the changed row from the database, thus allowing Oracle to set defaults for the columns and perform required calculations.
Usage
oradata1.OracleMode = [ True | False ]
Data Type
Integer
(Boolean)
Remarks
This property value is set to True
by default, which means that fields (columns) changes are reflected in the local cache immediately. Changing this property value has no effect until the Refresh
method is invoked. If the ORADB_ORAMODE
mode is used for the database option, the underlying recordset/dynaset inherits this mode.
Applies To
Description
Adds an argument to the OraIntervalDS
object.
Usage
OraIntervalDS.Add operand
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] operand | A Variant of type String , a numeric value, or an OraIntervalDS object to be added. |
Remarks
The result of the operation is stored in an OraIntervalDS
object, overwriting any previous value. There is no return value.
If operand
is a Variant
of type String
, it must be in the following format: [+/-]Day HH:MI:SSxFF.
If operand
is a numeric value, the value provided should represent the total number of days that the constructed OraIntervalDS
object represents.
Examples
Dim oraIDS as OraIntervalDS 'Create an OraIntervalDS using a string which represents '1 day and 12 hours Set oraIDS = oo4oSession.CreateOraIntervalDS("1 12:0:0.0") 'Add an interval using a string, which represents 2 days 'and 12 hours, to oraIDS. 'The resulting oraIDS is an interval which represents 4 days oraIDS.Add "2 12:0:0.0"
Applies To
Description
Returns the scale of a numeric column. Not available at design time and read-only at run time.
Usage
field_scale = orafield.OraScale
Data Type
Long
Integer
Remarks
This value is meaningful only when the value returned is numeric. The SQL types REAL
, DOUBLE
PRECISION
, FLOAT
, and FLOAT
(N
) return a scale of -127
.
Applies To
Description
Returns the index of the field indicated by the field_name
argument.
Usage
set index = oradynaset.FieldIndex(field_name)
Arguments
Arguments | Description |
---|---|
[in ] field_name | The name of the field as it appears in the SQL statement that the dynaset used most recently. |
Data Type
Integer
Remarks
Accessing fields of a dynaset using an index is more efficient than accessing them by name. If you need to access a particular field many times, use this method to translate its name into its index.
Applies To
Description
Returns the original column name used in the SELECT
statement in the dynaset (as opposed to the name of the field as it appears on the server returned by the Name
property). Not available at design time and read-only at run time.
Usage
field_name = Orafield.OriginalName
Remarks
The orafield.OriginalName
method returns the name of the specified OraField
object. This returns the Original
column name specified in the SQL statement during dynaset creation. This property is useful when a SQL statement contains 'schema.table.col'
as the Name
of the field. It enables duplicate column names to be referenced. (Duplicate column names can be avoided by using aliases in the SQL statement.)
Examples
The following example shows the use of the OriginalName
property. Copy and paste this code into the definition section of a form. Then, press F5.
Sub Form_Load () 'Declare variables Dim OraSession As OraSession Dim OraDatabase As OraDatabase Dim OraDynaset As OraDynaset Dim OraFields As OraFields 'Create the OraSession Object. Set OraSession = CreateObject("OracleInProcServer.XOraSession") 'Create the OraDatabase Object by opening a connection to Oracle. Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&) Set OraDynaset = OraDatabase.CreateDynaset("select scott.emp.deptno," & _ "dept.deptno from scott.emp, scott.dept where dept.deptno = emp.deptno", 0&) Set OraFields = OraDynaset.Fields 'Returns "DEPTNO" MsgBox OraFields(0).Name 'Returns "scott.emp.deptno" MsgBox OraFields(0).OriginalName 'Returns "dept.deptno" MsgBox OraFields(1).OriginalName End Sub
Applies To
Description
Adds an interval that represents an interval from years to months, to the OraTimeStamp
or OraTimeStampTZ
object.
Usage
OraTimeStampObj.AddIntervalYM operand OraTimeStampTZObj.AddIntervalYM operand
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] operand | A Variant of type String , a numeric value, or an OraIntervalYM object that represents an interval from years to months, to be added to the current OraTimeStamp or OraTimeStampTZ object. |
Remarks
The result of adding an interval to the current OraTimeStamp
or OraTimeStampTZ
object is stored in the current object, overwriting any previous value. There is no return value.
If operand
is a Variant
of type String
, it must be in following format: [+/-] YEARS-MONTHS.
If operand
is a numeric value, the value provided should represent the total number of years that the constructed OraIntervalYM
object represents.
Examples
Example: Using the OraTimeStamp Object
Dim OraTimeStamp As OraTimeStamp ... 'Create OraTimeStamp using a string Set OraTimeStamp = OraSession.CreateOraTimeStamp("2000-12-28 00:00:00", _ "YYYY-MM-DD HH:MI:SS") 'Add an interval using numeric value that represents 2 years OraTimeStamp.AddIntervalYM 2 'Value should now be "2002-12-28 00:00:00" tsStr = OraTimeStamp.Value ...
Example: Using the OraTimeStampTZ Object
Dim OraTimeStampTZ As OraTimeStampTZ ... 'Create OraTimeStampTZ using a string Set OraTimeStampTZ =OraSession.CreateOraTimeStampTZ("2000-12-28 00:00:00" & _ "-07:00" "YYYY-MM-DD HH:MI:SS TZH:TZM") 'Add an interval using numeric value that represents 2 years OraTimeStampTZ.AddIntervalYM 2 'Value should now be "2002-12-28 00:00:00" tstzStr = OraTimeStampTZ.Value ...
Applies To
Description
Returns the Bookmark
object of the row that was last modified by an Edit
or an AddNew
operation. Not available at design time and read-only at run time.
Usage
last_modified_bookmark = oradynaset.LastModified
Data Type
The value is a string of binary data, but can be stored in a variable of String
or Variant
data type. The length of the string cannot be predicted, so do not use a fixed-length string.
Remarks
Use this property to make the last modified record the current record.
Description
An OraAQ
object is instantiated by invoking the CreateAQ
method of the OraDatabase
interface. It represents a queue that is present in the database.
Remarks
Oracle Objects for OLE provides interfaces for accessing Oracle Database Advanced Queuing (AQ) feature. It makes AQ accessible from popular COM-based development environments such as Visual Basic.
The OraAQ
Automation interface provides methods for enqueuing and dequeuing messages (encapsulated in the OraAQMsg
object). It also provides a method for monitoring queues for message arrivals.
Client applications provide a Dispatch
interface to the monitor. The monitor checks the queue for messages that meet the application criteria. It then invokes the NotifyMe
method of the Dispatch
interface when these messages are dequeued.
The following diagram illustrates the OO4O AQ Automation objects and their properties.
Properties
Methods
Examples
Example: Enqueuing Messages
Enqueuing messages of type RAW
"Enqueuing Messages of Type RAW"
Enqueuing messages of Oracle object types
"Enqueuing Messages of Oracle Object Types"
Example: Dequeuing messages
NOTE: The following code samples serve as models for dequeuing messages.
A complete AQ sample can be found in \OO4O\VB\SAMPLES\AQ
Dequeuing messages of the RAW type
"Example: Dequeuing Messages of RAW Type"
Dequeuing messages of Oracle object types
"Example: Dequeuing Messages of Oracle Object Types"
Example: Monitoring messages
See "Monitoring Messages" for examples illustrating the use of the MonitorStart
and MonitorStop
methods.
See Also:
|
Applies To
Description
Returns the clone of an OraCollection
object.
Usage
set OraCollection1 = OraCollection.Clone
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] oraCollection1 | A valid OraCollection object |
Remarks
This method makes a copy of an Oracle collection and returns an OraCollection
object associated with that copy. This copy of an Oracle collection does not change due to a dynaset move operation or OraSQLStmt
Refresh
operation. An OraCollection
object returned by this method allows operations to access its element values of the underlying Oracle collection and prohibits any operation that modifies its element values.
Applies To
Description
Indicates whether or not a field value was truncated when fetched. Not available at design time and read-only at run time.
Usage
field_status = orafield.Truncated
Data Type
Integer
(Boolean)
Remarks
This property returns True
if truncated data is returned; otherwise, it returns False
. Truncation can only occur for LONG
or LONG
RAW
fields. Use this property to decide whether more data needs to be retrieved from an Oracle database using the GetChunk
method.
Description
An OraField
object represents a single column or data item within a row of a dynaset.
Remarks
An OraField
object is accessed indirectly by retrieving a field from the OraFields
collection of an OraDynaset
object.
If the current row is being updated, then the OraField
object represents the currently updated value, although the value may not yet have been committed to the database.
Assignment to the Value
property of a field is permitted only if a record is being edited (using the Edit
method) or a new record is being added (using the AddNew
method). Other attempts to assign data to the Value
property of a field results in an error.
Properties
Methods
Applies To
Description
Retrieves multiple records of a dynaset object into Variant
safe array.
Usage
Array =OraDynaset.GetRows(num_rows, start, fields )
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
num_rows [optional] | An Integer representing the number of records to retrieve. Default value is the total number of rows in the dynaset. |
start [optional] | An Integer representing the starting position of the dynaset from which the GetRows operation begins. Default value is the current position of the dynaset. |
fields [optional] | A Variant representing a single field name or field position, or an array of field names or array of field position numbers. The GetRows method returns only the data in these fields. |
Remarks
Use the GetRows
method to copy records from a dynaset into a two-dimensional array. The first subscript identifies the field and the second identifies the row number. The Array
variable is automatically dimensioned to the correct size when the GetRows
method returns the data.
Calling the GetRows
method does not change the current row position of the dynaset object.
Examples
The following example retrieves data using the GetRows
method.
Dim OraSession As OraSession Dim OraDatabase As OraDatabase Dim OraDynaset As OraDynaset Dim row, col As Integer Dim fields() As String 'Create the OraSession Object Set OraSession = CreateObject("OracleInProcServer.XOraSession") 'Create the OraDatabase Object by opening a connection to Oracle Set OraDatabase = OraSession.OpenDatabase("ExampleDb", _ "scott/tiger", 0&) Set OraDynaset = OraDatabase.CreateDynaset("select * from emp", 0&) 'The following line executes GetRows to get all records data_array = OraDynaset.GetRows() 'Now display all the data in data_array For row = 0 To UBound(data_array, 2) For col = 0 To UBound(data_array, 1) Debug.Print data_array(col, row) Next col Next row 'The following lines execute GetRows to get the data from 'the ename and empno fields starting at 5 ReDim fields(2) fields(0) = "EMPNO" fields(1) = "ENAME" 'Execute GetRows data_array = OraDynaset.GetRows(, 5, fields) 'Now display all the data in data_array For row = 0 To UBound(data_array, 2) For col = 0 To UBound(data_array, 1) Debug.Print data_array(col, row) Next col Next row
Applies To
Description
Gets or sets the total amount to be read or written for multiple chunk Read
and Write
operations (polling). A value of zero means that polling is not used. This property is read/write at run time.
Usage
pollamountbytes = OraBFile.PollingAmount OraBfile.PollingAmount = pollamountbytes pollamountbytes = OraBlob.PollingAmount OraBlob.PollingAmount = pollamountbytes pollamountchars= OraClob.PollingAmount OraClob.PollingAmount = pollamountchars
Data Type
Integer
Remarks
This value is expressed in bytes for the OraBLOB
and OraBFILE
objects, or characters for the OraCLOB
object. It is set before beginning a multiple-chunk read or write operation. After it is set, a series of Read
or Write
operations must be issued until the LOB Status
property no longer returns ORALOB_NEED_DATA
.This occurs when the PollingAmount
bytes or characters have been read. Attempting to do other LOB operations before the end of the polling operation results in an error.
Description
An OraDynaset
object permits browsing and updating of data created from a SQL SELECT
statement.
Remarks
An OraDynaset
object represents the result set of a SQL SELECT
query or a PL/SQL cursor variable returned from a stored procedure or function. It is essentially a client-side scrollable and updatable cursor that allows browsing the set of rows generated by the query it executes. It is created by the CreateDynaset
or CreateCustomDynaset
method of an OraDatabase
interface. An OraDynaset
object can be used to scroll result sets that contain instances of relational and object-relational columns such as VARRAY
s, nested tables, Object
s, REF
s, and LOBs and BFILE
types.
This object provides transparent mirroring of database operations, such as updates. When data is updated through the Update
method, the local mirror image of the query is updated so that the data appears to have been changed without reevaluating the query. The same procedure is used automatically when records are added to the dynaset. Integrity checking is performed to ensure that the mirrored image of the data always matches the actual data present on Oracle Database. This integrity checking is performed only when necessary (such as just before updates occur).
During create and refresh operations, the OraDynaset
objects automatically bind all relevant enabled input parameters to the specified SQL statement, using the parameter names as placeholders in the SQL statement. This can simplify dynamic query building and increase the efficiency of multiple queries using the same SQL statement with varying WHERE
clauses.
When you use Oracle Objects for OLE, locks are not placed on data until an Edit
method is executed. The Edit
method attempts to obtain a lock using the "SELECT
...
FOR
UPDATE"
statement on the current record of the dynaset. This is done as late as possible to minimize the time that locks are placed on the records. The Edit
method can fail for several reasons:
The SQL query violates the Oracle SQL update rules; for example, using calculated columns or table joins.
The user does not have the privileges needed to obtain a lock.
The record has been locked already by another user. Note that the OpenDatabase
method has an option so that you can decide whether to wait on locks.
Properties
Methods
Applies To
Description
Returns the next available OraDatabase
object from the pool.
Usage
GetDatabaseFromPool(long waitTime)
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
waitTime | The number of milliseconds this call waits for an object to be available, if the pool contains the maximum number of objects and all are used. |
Remarks
To retrieve an OraDatabase
object from the pool, the GetDatabaseFromPool
method is called. This function returns a reference to an OraDatabase
object. If the pool does not contain the maximum number of objects allowed, and all objects in the pool are used, then an additional OraDatabase
object is created implicitly. In addition, if a pool item contains an OraDatabase
object that has been timed out, then a new object is created and returned. The OraDatabase
object obtained from the pool is then marked as in use and is returned to the pool when the object is no longer referenced by the application.
Exceptions are raised by this call if:
The connection pool does not exist.
The pool contains no objects.
A time-out has occurred.
The LastServerErr
property of the OraSession
object contains the code for the specific cause of the exception.
Applies To
Description
Returns the current size of the given collection. Read-only at run time.
Usage
table_size = OraCollection.TableSize
Data Type
Integer
Remarks
For an OraCollection
object of type ORATYPE_TABLE
, it returns the current size of the collection, excluding deleted elements.
Applies To
Description
Returns the options flag originally passed to the specified object. Not available at design time and read-only at run time.
Usage
options = oradatabase.Options options = oradynaset.Options options = orasqlstmt.Options
Data Type
Long
Integer
Remarks
See the OpenDatabase
method for a description of the possible values of oradatabase.Options
.
See the CreateDynaset
method for a description of the possible values of oradynaset.Options
.
See the CreateSQL
method for a description of the possible values of orasqlstmt.Options
Applies To
Description
Clears the copy buffer and begins a record insertion operation into the specified dynaset and associated database.
Usage
oradynaset.AddNew oradynaset.DbAddNew
Remarks
When an AddNew
operation is initiated, values of fields present within the dynaset are maintained in a copy buffer and do not reflect the actual contents of the database.
The values of the fields are modified through the OraField
object, and committed with an Update
operation or when database movement occurs, which discards the new row. Field values that have not been explicitly assigned are either set to Null
or allowed to default by way of the Oracle default mechanism, depending on the Column Defaulting mode of the options flag used when the OpenDatabase
method was called. In either case, fields that appear in the database table but not in the dynaset are always defaulted by the Oracle default mechanism.
Internally, records are inserted by the AddNew
method using the "INSERT
into
TABLE
(...)
VALUES
(...)"
SQL statement, and are added to the end of the table.
When adding a row that has object, collection, and REF
columns, these column values should be set to a valid OraObject
, OraCollection
, or OraRef
interface or to the Null
value. The column values can also be set with the automation object returned by the CreateOraObject
method. When adding a row having a BLOB
, CLOB
, or BFILE
column, the column value should be set to a valid OraBLOB
, OraCLOB
, or OraBFILE
interface, Null
, or Empty
. Setting a BLOB
, CLOB
, and BFILE
column to an Empty
value inserts an empty LOB value into the database.
Note: A call toEdit , AddNew , or Delete methods cancels any outstanding Edit or AddNew method calls before proceeding. Any outstanding changes not saved using an Update method are lost during the cancellation. |
Examples
This example demonstrates the use of the AddNew
and Update
methods to add a new record to a dynaset. Copy this code into the definition section of a form. Then, press F5.
Sub Form_Load () 'Declare variables Dim OraSession As OraSession Dim OraDatabase As OraDatabase Dim OraDynaset As OraDynaset 'Create the OraSession Object. Set OraSession = CreateObject("OracleInProcServer.XOraSession") 'Create the OraDatabase Object by opening a connection to Oracle. Set OraDatabase = OraSession.OpenDatabase("ExampleDb", _ "scott/tiger", 0&) 'Create the OraDynaset Object. Set OraDynaset = OraDatabase.CreateDynaset("select * from emp", 0&) 'Begin an AddNew. OraDynaset.AddNew 'Set the field(column) values. OraDynaset.Fields("EMPNO").Value = "1000" OraDynaset.Fields("ENAME").Value = "WILSON" OraDynaset.Fields("JOB").Value = "SALESMAN" OraDynaset.Fields("MGR").Value = "7698" OraDynaset.Fields("HIREDATE").Value = "19-SEP-92" OraDynaset.Fields("SAL").Value = 2000 OraDynaset.Fields("COMM").Value = 500 OraDynaset.Fields("DEPTNO").Value = 30 'End the AddNew and Update the dynaset. OraDynaset.Update MsgBox "Added one new employee." End Sub
Applies To
Description
Checks if the OraIntervalYM object
is less than an argument.
Usage
isLess = OraIntervalYMObj.IsLess value
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] value | A Variant of type String , a numeric value, or an OraIntervalYM object to be compared. |
Remarks
Returns a Boolean value: The value is True
if the OraIntervalYM
object is less than the argument; otherwise, it is False
.
If value
is a Variant
of type String
, it must be in the following format: [+/-] YEARS-MONTHS.
If value
is a numeric value, the value provided should represent the total number of years that the constructed OraIntervalYM
object represents.
Applies To
Description
Applicable only for a dequeue operation.
Usage
Q.Consumer = consumer_name
Data Type
String
Remarks
The value is a string representing the name of the consumer. Only those messages matching the consumer name are accessed.
Examples
Dim DB As OraDatabase Dim Q as OraAQ set Q = DB.CreateAQ("Q_MSG_MULTIPLE") 'Dequeue only message meant for ANDY Q.consumer = "ANDY" 'other processing... Q.Dequeue
Description
The OraAQMsg
object encapsulates the message to be enqueued or dequeued. The message can be of any user-defined or raw type.
Properties
Methods
See Also:
|
This chapter describes the Oracle Objects for OLE Server methods.
For an introduction to OO4O server objects, see "Oracle Objects for OLE In-Process Automation Server" .
This chapter contains these topics:
Server Methods: A to B
Server Methods: C
Server Methods: D to H
Server Methods: I to L
Server Methods: M to S
Server Methods: T to Z
Applies To
Description
Appends the LOB content of the input OraLOB object to the internal LOB value of this instance.
Usage
OraBlob.Append srcBlob OraClob.Append srcClob
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] srcLOB | A valid object of type OraBLOB or OraCLOB . |
Remarks
Appends the LOB content of input LOB to the end of current LOB value. Obtain either a row-level lock or an object-level lock before calling this method.
Applies To
Description
Determines whether trailing blanks should be removed from character string data retrieved from the database. Read/write at design time and run time.
Usage
oradata1.TrailingBlanks = [ True | False ]
Data Type
Integer
(Boolean)
Remarks
By default, TrailingBlanks
is False
. This means that trailing blanks will be removed from character string data retrieved from the database.
Changing this property has no effect until a Refresh
method is sent to the data control.
Applies To
Description
Returns True
if an element exists at a given index; otherwise, returns. Valid only for OraCollection
of Type ORATYPE_TABLE
.
Usage
exists = OraCollection.Exist index
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[out ] exists | A Boolean value specifying the existence status of the element. |
[in ] index | An Integer specifying the index of the element. |
Remarks
None.
Applies To
Description
Returns the number of OraAttribute
objects in the collection. This is same as the total number of attributes of the underlying referenceable object of OraRef
or underlying value instance of OraObject
. Read-only at run time.
Usage
attrcount = OraRef.Count attrcount = OraObject.Count
Data Type
Integer
Remarks
Individual attributes can be accessed by using a subscript or the name of the attribute. The OraObject
or OraRef
attribute index starts at 1
.
Examples
The following example shows the use of the Count
property. Before running the sample code, make sure that you have the necessary data types and tables in the database. See "Schema Objects Used in the OraObject and OraRef Examples".
Dim OraSession as OraSession Dim OraDatabase as OraDatabase Dim OraDynaset as OraDynaset Dim Address as OraObject 'Create the OraSession Object. Set OraSession = CreateObject("OracleInProcServer.XOraSession") 'Create the OraDatabase Object by opening a connection to Oracle. Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&) 'create a dynaset object from person_tab set OraDynaset = OraDatabase.CreateDynaset("select * from person_tab",0&) 'retrieve a address column from person_tab. 'Here Value property of OraField object returns Address OraObject set Address = OraDynaset.Fields("Addr").Value 'access the attribute by dot notation msgbox Address.Street 'access the attribute using '!' notation ( early binding application) msgbox Address!Street 'access the attribute by index msgbox Address(1) 'access the attribute by name msgbox Address("Street") 'access all the attributes of Address OraObject in the dynaset Do Until OraDynaset.EOF For index = 1 To Address.Count msgbox Address(index) Next Index OraDynaset.MoveNext Loop
Applies To
Description
The SQL SELECT
statement to be used to create the data control's RecordSet
. Read/write at design time and run time.
Usage
oradata1.RecordSource = [ SQL SELECT Statement ]
Data Type
String
Remarks
The SQL statement must be a SELECT
statement; otherwise an error is returned. Features such as views, synonyms, column aliases, schema references, table joins, nested selects, and remote database references can be used freely; object names are not modified in any way.
Whether or not the resultant dynaset can be updated depends on the Oracle SQL rules of updatability, the access you have been granted, and the ReadOnly
property. In order to be updatable, three conditions must be met:
The SQL statement must refer to a simple column list or to the entire column list (*).
The SQL statement must not set the read-only flag of the options argument.
Oracle must permit ROWID references to the selected rows of the query.
Any SQL statement that does not meet these criteria is processed, but the results are not updatable and the dynaset's Updatable
property returns False
.
Changing this property does not take effect until a Refresh
method is sent to the data control.
You can use SQL bind variables in conjunction with the OraParameters
collection.
If this property is NULL
or empty, then an OraDynaset
object is not created, but OraSession
, OraConnection
, and OraDatabase
objects are created for the data control. This behavior enables access to these objects prior to creation of a dynaset. For example, a NULL
RecordSource
might be used to instantiate the database object to add parameters. The RecordSource
property can then be set at run time, making use of the automatic binding of database parameters.
Changing this property and calling the Refresh
method of the RecordSet
property will create a new dynaset object, but the old dynaset continues to be available for use until all references to it are removed.
Example
This example demonstrates the use of SQL bind variables (parameters) in the RecordSource
property of the data control. To run this demonstration, copy this code into the definition section of a form containing a data control named oradata1
, then, press F5.
Sub Form_Load () 'Set the username and password. oradata1.Connect = "scott/tiger" 'Set the databasename. oradata1.DatabaseName = "ExampleDb" 'Refresh the data control without setting the ' RecordSource. This has the effect of creating ' the underlying database object so that parameters may be added. oradata1.Refresh 'Set the RecordSource and use a SQL parameter. oradata1.RecordSource = "select * from emp where job = :job" 'Add the job input parameter with initial value MANAGER. oradata1.Database.Parameters.Add "job", "MANAGER", 1 'Refresh the data control. 'Only employees with the job MANAGER will be contained in the dynaset. oradata1.Refresh 'Change the value of the job parameter to SALESMAN. oradata1.Database.Parameters("job").Value = "SALESMAN" 'Refresh ONLY the recordset. 'Only employees with the job SALESMAN will be contained in the dynaset. oradata1.Recordset.Refresh End Sub
Applies To
Description
Returns the name used to identify the given object. Not available at design time and read-only at run time.
Usage
client_name = oraclient.Name field_name = orafield.Name parameter_name = oraparameter.Name paramarray_name = oraparamarray.Name session_name = orasession.Name server_name = oraserver.Name subscription_name = orasubscription.Name
Data Type
String
Remarks
oraclient.Name
Returns the name of the specified OraClient
object. This value is always local.
orafield.Name
Returns the name of the specified OraField
object. If this is a true database field (not an alias), this use returns the name of the field as it appears in the database. If a SQL statement was executed that contains, for example, calculated select list items or column aliases, then the name is the actual text provided in the SQL SELECT
statement.
oraparameter.Name
Returns the name of the specified OraParameter
object. In addition to identifying the parameter within a parameters collection, the parameter name is also used to match placeholders within SQL and PL/SQL statements for the purposes of parameter binding.
oraparamarray.Name
Returns the name of the specified OraParamArray
object. In addition to identifying the parameter within a parameters collection, the parameter name is also used to match placeholders within SQL and PL/SQL statements for the purposes of parameter binding.
orasession.Name
Returns the name of the specified OraSession
object. For automatically created sessions, this is the name assigned by the system (usually a hexadecimal number). For user-created sessions, this is the name originally provided in the CreateSession
method. Once created, a session name cannot be changed.
oraserver.Name
Returns the name of the physical connection of the specified OraServer
object.
orasubscription.Name
Returns the name used to represent the subscription. Name
here refers to the subscription name in the form of the string 'SCHEMA.QUEUE'
if the registration is for a single consumer queue and 'SCHEMA.QUEUE:CONSUMER_NAME'
if the registration is for a multiple consumer queue.
Applies To
Description
Specifies the name of the queue to which message should be moved if it cannot be processed successfully.
Usage
Msg.ExceptionQueue queue_name
Data Type
String
Remarks
Applicable only for a message that is being enqueued.
Possible values are:
A String
containing a valid queue name
Null
(Default)
A message is moved to the exception queue if the number of dequeue attempts has expired or has exceeded max_retries specified in the DBMS_AQADM.CREATE_QUEUE
command.
Applies To
Description
Generates an XML document and writes it to a file.
Usage
oradynaset.GetXMLToFile (filename, startrow, maxrows)
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
filename | The file name that the XML is written to. Existing files by the same name are overwritten. |
startrow | The row identifier indicating from which row to start (see OraDynaset.RowPosition ). The default value of this argument is 0 (the first row). |
maxrows | The maximum number of rows to retrieve (if the end of the record set is reached; fewer rows may be returned). If this argument is omitted, then all rows are returned. |
Remarks
There is no return value.
The formatting of the XML output can be customized through the XML properties of the OraDynaset
and OraField
objects.
Description
Each OraMDAttribute
object describes an individual attribute. It represents an entry to the attribute table of the OraMetaData
object. It can be accessed by creating a subscript that uses ordinal integers or by using the name of the attribute.
Remarks
None.
Properties
Methods
None.
Examples
See "Schema Objects Used in OraMetaData Examples" for OraMetaData
Schema Definitions used in these examples.
Example: Describing a Table
See "Describing a Table Example".
Example: Describing a User-Defined Type
See "Example: Describing a User-Defined Type".
Example: Describing Unknown Schema Objects
See "Example: Describing Unknown Schema Objects".
Applies To
Description
Gets or sets the element values from the Variant
SAFEARRAY
.
Usage
SafeArray = OraCollection.SafeArrayOraCollection.SafeArray = SafeArray
Arguments
Arguments | Description |
---|---|
SafeArray | A Variant representing SafeArray format. |
Data Type
A Variant
representing a SafeArray
format.
Remarks
This property is only valid for simple scalar elements types, such as VARCHAR2
and NUMBER
. This property raises an error for element type LOBS, Objects, Refs, and so on.
The Variant
SAFEARRAY
index starts at 0
. When converting to SAFEARRAY
format, the OraCollection
object converts its element value to its corresponding SAFEARRAY
Variant
type. The following table explains collection element types and their corresponding SAFEARRAY
Variant
types:
Collection Element Type | SAFEARRAY of |
---|---|
Date | String |
Number | String |
CHAR , VARCHAR2 | String |
Real | Real |
Integer | Integer |
For setting a SAFEARRAY
to a collection, OraCollection
converts the SAFEARRAY
elements to its nearest collection element type.
Description
The OraNumber
interface provides methods for operations on the Oracle Number
data types. This interface exposes a set of math operations that provide greater precision than is available in some programming environments, such as Visual Basic.
Remarks
The OraNumber
object can be obtained through the CreateOraNumber
method of the OraSession
object or by calling the Clone
method on an existing OraNumber
.
All of the methods of the OraNumber
object that take a numeric argument accept a string, another numeric type, such as a long
in Visual Basic, or another OraNumber
object.
Note: If a Visual Basic numeric value (or constant) is used as an argument, it is limited to the maximum precision provided by the language. |
The OraNumber
on which the math operation is called holds the result of the operation (overwriting any previous value). If a Format
was specified (through the Format
property), the value of an OraNumber
must match this format or an error is raised when the Value
property is accessed.
Properties
Methods
Example
A scientific calculator example program is included as part on the samples installed with Oracle Objects for OLE. See "Demonstration Schema and Code Examples".
Applies To
Description
Returns a String
containing the bytes of all or a portion of a LONG
or LONG
RAW
field.
Usage
data_string = orafield.ReadChunk(offset, numbytes, bytesread)
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
offset | The number of bytes in the field to skip before copying data. |
numbytes | The number of bytes to copy. |
bytesread | The number of bytes read. |
Remarks
The ReadChunk
method behaves like the GetChunk
method, but it returns the actual number of bytes read in the bytesread
argument.
This appendix includes the following:
The following are code for Oracle data types.
Table A-1 Oracle Data Type Codes
Oracle Data Type | Codes |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
These codes are also listed in the oraconst.txt
file located in the ORACLE_BASE\\ORACLE_HOME
\oo4o
directory.
Occasionally other schemas are required to run examples. These schemas are listed in the following sections.
This section presents OraMetaData schema definitions.
CREATE TYPE ORAMD_ADDRESS AS OBJECT ( no NUMBER, street VARCHAR(60), state CHAR(2), zip CHAR(10), MEMBER PROCEDURE ChangeStreetName(newstreet IN VARCHAR2) );
The following schema objects are used in the OraLOB and BFILE
examples. Run the SQL script ORAEXAMP.SQL
on your database to set up the schema.
CREATE TABLE part ( part_id NUMBER, part_name VARCHAR2(20), part_image BLOB, part_desc CLOB, part_collateral BFILE ); Create Directory NewDirectoryName as 'C:\valid\path'
The following schema objects are used in the OraObject
and OraRef
examples. Data for the following tables can be inserted with the ORAEXAMP.SQL
script that is provided with the OO4O installation.
CREATE TYPE address AS OBJECT ( street VARCHAR2(200), city VARCHAR2(200), state CHAR(2), zip VARCHAR2(20) ); CREATE TYPE person as OBJECT( name VARCHAR2(20), age NUMBER, addr ADDRESS); CREATE TABLE person_tab of PERSON; CREATE TABLE customers( account NUMBER, aperson REF PERSON);
The following schema is used in examples of OraCollection
methods
CREATE TYPE ENAMELIST AS VARRAY(20) OF VARCHAR2(30); CREATE TABLE department ( dept_id NUMBER(2), name VARCHAR2(15), ENAMES ENAMELIST); DROP TYPE COURSE; CREATE TYPE Course AS OBJECT ( course_no NUMBER(4), title VARCHAR2(35), credits NUMBER(1)); CREATE TYPE CourseList AS TABLE OF Course; CREATE TABLE division ( name VARCHAR2(20), director VARCHAR2(20), office VARCHAR2(20), courses CourseList) NESTED TABLE courses STORE AS courses_tab;
Applies To
Description
Does nothing. Added for compatibility with Visual Basic.
Remarks
Neither the OraDatabase
nor the OraDynaset
object supports this method. Once an OraDatabase
or OraDynaset
object has gone out of scope and there are no references to it, the object closes automatically.
Applies To
Description
Dequeues a message.
Usage
Q.Dequeue()
Remarks
The message attributes can be accessed with the OraAQMsg
interface contained in this object. On success, this method returns the message identifier as an array of bytes. Otherwise, it returns an empty array (null).
Examples
Note: The following code sample are models for dequeuing messages.A complete AQ sample can be found in the |
Example: Dequeuing Messages of RAW Type
'Dequeue the first message available Q.Dequeue Set Msg = Q.QMsg 'Display the message content MsgBox Msg.Value 'Dequeue the first message available without removing it ' from the queue Q.DequeueMode = ORAAQ_DQ_BROWSE 'Dequeue the first message with the correlation identifier ' equal to "RELATIVE_MSG_ID" Q.Navigation = ORAAQ_DQ_FIRST_MSG Q.correlate = "RELATIVE_MESSAGE_ID" Q.Dequeue 'Dequeue the next message with the correlation identifier ' of "RELATIVE_MSG_ID" Q.Navigation = ORAAQ_DQ_NEXT_MSG Q.Dequeue 'Dequeue the first high priority message Msg.Priority = ORAQMSG_HIGH_PRIORITY Q.Dequeue 'Dequeue the message enqueued with message id of Msgid_1 Q.DequeueMsgid = Msgid_1 Q.Dequeue 'Dequeue the message meant for the consumer "ANDY" Q.consumer = "ANDY" Q.Dequeue 'Return immediately if there is no message on the queue Q.wait = ORAAQ_DQ_NOWAIT Q.Dequeue
Example: Dequeuing Messages of Oracle Object Types
Set OraObj = DB.CreateOraObject("MESSAGE_TYPE") Set QMsg = Q.AQMsg(23, "MESSAGE_TYPE","SCOTT") 'Dequeue the first message available without removing it Q.Dequeue OraObj = QMsg.Value 'Display the subject and data MsgBox OraObj("subject").Value & OraObj("Data").Value
Applies To
Description
Divides the OraIntervalYM
object by a divisor.
Usage
OraIntervalYMObj.Div divisor
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] divisor | A Variant for type numeric value or an OraNumber object to be used as the divisor. |
Remarks
The result of the operation is stored in the OraIntervalYM
object, overwriting any previous value. There is no return value.
Applies To
Description
Determines whether or not Update
and Delete
will
or will not check for read inconsistencies.
Usage
oradata1.DirtyWrite = [ True | False ]
Data Type
Integer
(Boolean)
Remarks
By default, DirtyWrite
is False
, meaning that read consistency will be maintained for Update
and Delete
operation on underlying recordset/dynaset object. Changing this property has no effect until a Refresh
method is sent to the data control.
Applies To
Description
Adds an interval that represents an interval from days to seconds, to the OraTimeStamp
or OraTimeStampTZ
object.
Usage
OraTimeStampObj.AddIntervalDS operand OraTimeStampTZObj.AddIntervalDS operand
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] operand | A Variant of type String , a numeric value, or an OraIntervalDS object that represents an interval from days to seconds to be added to the current OraTimeStamp or OraTimeStampTZ object. |
Remarks
The result of adding an interval to the current OraTimeStamp
or OraTimeStampTZ
object is stored in the current object, overwriting any previous value. There is no return value.
If operand
is a Variant
of type String
, it must be in the following format: [+/-] Day HH:MI:SSxFF.
If operand
is a numeric value, the value provided should represent the total number of days that the constructed OraIntervalDS
object represents.
Examples
Using OraTimeStamp
Dim OraTimeStamp As OraTimeStamp ... 'Create OraTimeStamp using a string Set OraTimeStamp = OraSession.CreateOraTimeStamp("2000-12-28 00:00:00", _ "YYYY-MM-DD HH:MI:SS") 'Add an interval using numeric value that represents 5 days and 12 hours OraTimeStamp.AddIntervalDS 5.5 'Value should now be "2001-1-2 12:00:00" tsStr = OraTimeStamp.Value
Using OraTimeStampTZ
Dim OraTimeStampTZ As OraTimeStampTZ ... 'Create OraTimeStampTZ using a string Set OraTimeStamp = OraSession.CreateOraTimeStampTZ("2000-12-28 00:00:00 -07:00", _ "YYYY-MM-DD HH:MI:SS TZH:TZM") 'Add an interval using numeric value that represents 5 days and 12 hours OraTimeStampTZ.AddIntervalDS 5.5 'Value should now be "2001-1-2 12:00:00" tstzStr = OraTimeStampTZ.Value ...
Applies To
Description
Specifies the Oracle external type of a SQL or PL/SQL bind variable. Not available at design time and read/write at run time.
Read-only for the OraParamArray
object. Specify the ServerType
property during the AddTable
method.
Usage
oraparameter.ServerType = oracle_type
Data Type
Integer
Remarks
Used to specify the external data type of SQL or PL/SQL (in/out) bind variables. This is necessary because no local parsing of the SQL statement or PL/SQL block is done to match the data types of placeholders in the SQL statement or PL/SQL block.
After an OraParameter
object has been set to ServerType
BLOB
, CLOB
, BFILE
, OBJECT
, REF
, VARRAY
, or NESTED
TABLE
, it cannot be changed to any other ServerType
property.
The following Oracle external data types are supported.
Constant | Value | Internal Data Type |
---|---|---|
ORATYPE_VARCHAR2 | 1 | VARCHAR2 |
ORATYPE_NUMBER | 2 | NUMBER |
ORATYPE_SINT | 3 | SIGNED INTEGER |
ORATYPE_FLOAT | 4 | FLOAT |
ORATYPE_STRING | 5 | Null Terminated STRING |
ORATYPE_LONG | 8 | LONG |
ORATYPE_VARCHAR | 9 | VARCHAR |
ORATYPE_DATE | 12 | DATE |
ORATYPE_RAW | 23 | RAW |
ORATYPE_LONGRAW | 24 | LONG RAW |
ORATYPE_UINT | 68 | UNSIGNED INTEGER |
ORATYPE_CHAR | 96 | CHAR |
ORATYPE_CHARZ | 97 | Null Terminated CHAR |
ORATYPE_BFLOAT | 100 | BINARY_FLOAT |
ORATYPE_BDOUBLE | 101 | BINARY_DOUBLE |
ORATYPE_CURSOR | 102 | PLSQL CURSOR |
ORATYPE_MLSLABEL | 105 | MLSLABEL |
ORATYPE_OBJECT | 108 | OBJECT |
ORATYPE_REF | 110 | REF |
ORATYPE_CLOB | 112 | CLOB |
ORATYPE_BLOB | 113 | BLOB |
ORATYPE_BFILE | 114 | BFILE |
ORATYPE_TIMESTAMP | 187 | TIMESTAMP |
ORATYPE_TIMESTAMPTZ | 188 | TIMESTAMP WITH TIMEZONE |
ORATYPE_INTERVALYM | 189 | INTERVAL YEAR TO MONTH |
ORATYPE_INTERVALDS | 190 | INTERVAL DAY TO SECOND |
ORATYPE_TIMESTAMPLTZ | 232 | TIMESTAMP WITH LOCAL TIME ZONE |
ORATYPE_VARRAY | 247 | VARRAY |
ORATYPE_TABLE | 248 | NESTED TABLE |
ORATYPE_RAW_BIN | 2000 | RAW |
These values can be found in the ORACLE_BASE\\ORACLE_HOME
\oo4o\oraconst.txt
file.
Examples
This example demonstrates the Add
and Remove
parameter methods, the ServerType
parameter property, and the ExecuteSQL
database method to call a stored procedure and function (located in ORAEXAMP.SQL
). Copy and paste this code into the definition section of a form. Then, press F5.
Sub Form_Load () 'Declare variables as OLE Objects. Dim OraSession As OraSession Dim OraDatabase As OraDatabase Dim OraDynaset As OraDynaset 'Create the OraSession Object. Set OraSession = CreateObject("OracleInProcServer.XOraSession") 'Create the OraDatabase Object. Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&) 'Add EMPNO as an Input/Output parameter and set its initial value. OraDatabase.Parameters.Add "EMPNO", 7369, ORAPARM_INPUT OraDatabase.Parameters("EMPNO").ServerType = ORATYPE_NUMBER 'Add ENAME as an Output parameter and set its initial value. OraDatabase.Parameters.Add "ENAME", 0, ORAPARM_OUTPUT OraDatabase.Parameters("ENAME").ServerType = ORATYPE_VARCHAR2 'Add SAL as an Output parameter and set its initial value. OraDatabase.Parameters.Add "SAL", 0, ORAPARM_OUTPUT OraDatabase.Parameters("SAL").ServerType = ORATYPE_NUMBER 'Execute the Stored Procedure Employee.GetEmpName to retrieve ENAME. ' This Stored Procedure can be found in the file ORAEXAMP.SQL. OraDatabase.ExecuteSQL ("Begin Employee.GetEmpName (:EMPNO, :ENAME); end;") 'Display the employee number and name. 'Execute the Stored Function Employee.GetSal to retrieve SAL. ' This Stored Function can be found in the file ORAEXAMP.SQL. OraDatabase.ExecuteSQL ("declare SAL number(7,2); Begin" & _ ":SAL:=Employee.GetEmpSal (:EMPNO); end;") 'Display the employee name, number and salary. MsgBox "Employee " & OraDatabase.Parameters("ENAME").value & ", #" & OraDatabase.Parameters("EMPNO").value & ",Salary=" & OraDatabase.Parameters("SAL").value 'Remove the Parameters. OraDatabase.Parameters.Remove "EMPNO" OraDatabase.Parameters.Remove "ENAME" OraDatabase.Parameters.Remove "SAL" End Sub
This section describes new features of Oracle Database 11g Release 2 (11.2) and provides pointers to additional information. New features information from previous releases is also retained to help those users migrating to the current release.
The following sections describe the new features in Oracle Oracle Objects for OLE:
There are no new features for these releases.
There are no new features for this release.
Documentation for Oracle Objects for OLE was improved and reorganized, although there is no additional content. The documentation was reformatted to a printable, PDF format. PDF and HTML are provided in the Documentation Library. Online Help in WinHelp format is no longer provided.
Support for Oracle Grid Computing
Oracle Objects for OLE is grid-enabled, allowing developers to take advantage of Oracle database grid support without having to make changes to their application code.
Support for New Data Types
Oracle Objects for OLE provides support for the BINARY_DOUBLE
and BINARY_FLOAT
data types introduced in Oracle Database 10g. Instances of these types can be fetched from the database or passed as input or output variables to SQL statements and PL/SQL locks, including stored procedures and functions.
The following constants were added in the oraconst.txt
to bind the BINARY_DOUBLE
and BINARY_FLOAT
data types.
ORATYPE_BDOUBLE
, Oracle data type BINARY_DOUBLE
, value 101
ORATYPE_BFLOAT
, Oracle data type BINARY_FLOAT
, value 100
Support for Multiple Oracle Homes
Oracle Objects for OLE can be installed in multiple Oracle homes, starting with release 10.1. However, being a Component Object Model (COM) component, only one instance can be active on the computer. This means that the current (latest) installation renders the previous one inactive.
To make multiple Oracle homes available, the use of a KEY_
HOMENAME
is required. Also, some of the Oracle Objects for OLE files include a version number.
Applies To
Description
Creates a pool of OraDatabase
objects. Only one pool can be created for each OraSession
object.
Usage
CreateDatabasePool (long initialSize, long maxSize, long timeoutValue, BSTR database_name, BSTR connect_string, long options)
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
initialSize | The initial size of the pool. |
maxSize | The maximum size to which the pool can grow. |
timeoutValue | If an OraDatabase object in the pool is idle for the timeoutValue value specified, the database connection that it contains is disconnected. The connection is reopened if the pool item is used again. This value is in seconds. |
database_name | The Oracle network specifier used when connecting the data control to a database. |
connectString | The user name and password to be used when connecting to an Oracle database. |
options | A bit flag word used to set the optional modes of the database. If options = 0 , the default mode settings apply. "Constants" shows the available modes. |
Remarks
The OpenDatabase
method of the OraSession
object is used to establish a connection to an Oracle database. This method returns a reference to the OraDatabase
object which is then used for executing SQL statements and PL/SQL blocks. The connection pool in OO4O is a pool of OraDatabase
objects. The pool is created by invoking the CreateDatabasePool
method of the OraSession
interface.
Exceptions are raised by this call if:
A pool already exists.
An error occurs in creating a connection to Oracle Database.
Invalid values for arguments are passed (that is, initialSize
> maxSize
).
The LastServerErr
property of the OraSession
object contains the code for the specific cause of the exception resulting from an Oracle Database error.
One possible connection error that could be returned is:
ORA-28001 "the password has expired"
The user can change the password using the ChangePassword
method.
Applies To
Description
Returns the value of a particular element of the array at the specified index.
Usage
OraParamArray.Get_Value(array, index)
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] array | A String representing the name of the array. |
[in ] index | An Integer representing the index value of the object. |
Remarks
The OraParamArray.Get_Value
method returns the value of the field as a Variant
. The value of data_value
=
oraparameter.Value
sets the contents of the parameter.
Note that fields of type DATE
are returned in the default Visual Basic format as specified in the Control Panel, even though the default Oracle date format is "DD-MMM-YY".
The Value
argument can be an Oracle Database 10g object, such as an OraBLOB
object. For Put_Value
, a copy of the object is made at that point in time, and Get_Value
must be accessed to obtain a new object that refers to that index value. For example, if iotype
is ORATYPE_BOTH
and an OraBLOB
object obtained from a dynaset is passed in as the input value, Get_Value
needs to be called after the SQL code has been executed to obtain the newly updated output value of the ParamaterArray
object.
Similar to a dynaset, the object obtained from the ParamaterArray
Get_Value
property refers to the latest value for that ParamaterArray
index. The Visual Basic value Null
can also be passed as a value. The Visual Basic value EMPTY
can be used for BLOB
and CLOB
to indicate an empty LOB, and for Object
, VARRAY
, and nested table data types to indicate an object whose attributes are all Null
.
This method is not available at design time and is read-only at run time.
When binding to RAW
columns (ServerType
ORATYPE_RAW_BIN
), the value should be a byte array.
This chapter describes the Oracle Data Control Properties. For an introduction to Data Control, see "Oracle Data Control".
See Also: For more information, see the Microsoft Visual Basic help and documentation. |
This chapter contains these topics:
The following properties apply to the OraDynaset
object and to the Oracle Data Control.
Description
An OraConnection
object represents a single connection to an Oracle database.
Remarks
An OraConnection
object is created automatically whenever an OraDatabase
object is instantiated within the session, and it is destroyed automatically whenever all databases using the connection are discarded.
Currently, there is no way to create an OraConnection
object explicitly, only by creating an OraDatabase
object that requires a connection.
Properties
Methods
Applies To
Description
Adds a numeric argument to the OraNumber
object.
Usage
OraNumber.Add operand
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] operand | A Variant of type String , OraNumber object, or a numeric value. |
Remarks
The result of the operation is stored in an OraNumber
object. There is no return value.
Applies To
Description
Checks if an OraNumber
object is less than an argument value.
Usage
bool = OraNumber.IsLess value
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] value | A Variant of type String , OraNumber object, or a numeric value. |
Remarks
Returns a Boolean value: The value is True
if the OraNumber object is less than the argument; otherwise, it is False
.
Applies To
Description
Creates a new OraTimeStampTZ
object. This OraTimeStampTZ
object represents an Oracle TIMESTAMP
WITH
TIME
ZONE
data type.
Usage
Set OraTimeStampTZObj = OraSession.CreateOraTimeStampTZ value format
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] value | A Variant of type String , Date , or OraTimeStampTZ . |
[[in ] [optional] format | TIMESTAMP WITH TIME ZONE format string to be used when displaying or interpreting an OraTimeStampTZ object as a string. If format is not specified, the TIMESTAMP WITH TIME ZONE string is interpreted using the session TIMESTAMP WITH TIME ZONE format (NLS_TIMESTAMP_TZ_FORMAT format). |
Return Values
Remarks
An OraSession
object must be created before an OraTimeStampTZ
object can be created.
If value
is a Variant
of type String
, the string format must match the datetime format specified in the format argument if format is specified; otherwise, the string format must match the session TIMESTAMP
WITH
TIME
ZONE
format (NLS_TIMESTAMP_TZ_FORMAT
).
If value
is a Variant
of type Date
, the date-time value in the Date
is interpreted as the date-time value in the time zone of the session. The TimeZone
property in the OraTimeStampTZ
object contains the time zone of the session.
If format
is specified, it is stored in the Format
property of the OraTimeStampTZ
object, otherwise the session TIMESTAMP
WITH
TIME
ZONE
format is stored in the Format
property of OraTimeStampTZ
object.
Examples
Dim oraTSZ as OraTimeStampTZ Dim oraTSZ1 as OraTimeStampTZ Dim date as Date 'Create an OraTimeStampTZ using a string assuming the session 'TIMESTAMP WITH TIME ZONE format is "DD-MON-RR HH.MI.SSXFF AM TZH:TZM" Set oraTSZ = oo4oSession.CreateOraTimeStampTZ( "12-JAN-2003" & _ "12.0.0.0 PM -03:00") 'Create an OraTimeStampTZ using a string and a format Set oraTSZ = oo4oSession.CreateOraTimeStampTZ( "2003-01-12" & _ "12:00:00 PM -03:00", "YYYY-MM-DD HH:MI:SS AM TZH:TZM") 'Create an OraTimeStampTZ using a Date date = #1/12/2003# Set oraTSZ = oo4oSession.CreateOraTimeStampTZ(date) 'Create an OraTimeStampTZ using an OraTimeStampTZ Set oraTSZ1 = oo4oSession.CreateOraTimeStampTZ(oraTSZ)
Applies To
Description
Creates a dynaset using custom cache and fetch parameters
Usage
Set oradynaset = oradatabase.CreateCustomDynaset(sql_statement, options, slicesize, perblock, blocks, FetchLimit, FetchSize, SnapShotID)
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
sql_statement | Any valid Oracle SQL SELECT statement. |
slicesize | Cache slice size. |
perblock | Cache slices for each block. |
blocks | Cache maximum number of blocks. |
FetchLimit | Fetch array size. |
FetchSize | Fetch array buffer size. |
options | A bit flag indicating the status of any optional states of the dynaset. You can combine one or more options by adding their respective values. Specifying the constant ORADYN_DEFAULT or the value &H0& gives the following defaults for the dynaset:
|
SnapShotID [optional] | The ID of a Snapshot obtained from the SnapShot property of an OraDynaset . |
Constants
The following table lists constants and values for the options flag.
Constant | Value | Description |
---|---|---|
ORADYN_DEFAULT | &H0& | Accept the default behavior. |
ORADYN_NO_AUTOBIND | &H1& | Do not perform automatic binding of database parameters. |
ORADYN_NO_BLANKSTRIP | &H2& | Do not remove trailing blanks from character string data retrieved from the database. |
ORADYN_READONLY | &H4& | Force dynaset to be read-only. |
ORADYN_NOCACHE | &H8& | Do not create a local dynaset data cache. Without the local cache, previous rows within a dynaset are unavailable; however, increased performance results during retrieval of data from the database (move operations) and from the rows (field operations). Use this option in applications that make single passes through the rows of a dynaset for increased performance and decreased resource usage. |
ORADYN_ORAMODE | &H10& | Same as Oracle Mode for a database except it affects only the dynaset being created. If database was created in Oracle Mode, the dynaset inherits the property from it (for compatibility). |
ORADYN_NO_REFETCH | &H20& | Behaves same as ORADB_NO_REFETCH mode for a database except this mode affects only the dynaset being created. If the database was created in ORADB_NO_REFETCH mode, the dynaset inherits the property for compatibility. |
ORADYN_N_MOVEFIRST | &H40& | Does not force a MoveFirst when the dynaset is created. BOF and EOF are both true. |
ORADYN_DIRTY_WRITE | &H80& | Update and Delete methods do not check for read consistency. |
These values can be found in the oraconst.txt
file located in:
ORACLE_BASE\\ORACLE_HOME
\rdbms\oo4o
Remarks
The SQL statement must be a SELECT
statement or an error is returned. Features such as simple views and synonyms can be used freely. You can also use schema references, column aliases, table joins, nested select statements, and remote database references, but in each case you end up with a read-only dynaset.
If you use a complex expression or SQL function on a column, such as "sal + 100"
or "abs(sal)"
, you get an updatable dynaset, but the column associated with the complex expression is not updatable.
Object names generally are not modifed, but in certain cases, they can be changed. For example, if you use a column alias, you must use the alias to refer to the field by name. If you use spaces in a complex expression, you must refer to the column without the spaces, because the database removes spaces. Note that you can always refer to a field by number, that is, by its ordinal position in the SELECT
statement.
Executing the SQL SELECT
statement generates a commit operation to the database by default. To avoid this, use the BeginTrans
method on the session object before using the CreateDynaset
method.
The updatability of the resultant dynaset depends on the Oracle SQL rules of updatability, on the access you have been granted, and on the options flag.
Updatability Conditions
For the dynaset to be updatable, three conditions must be met:
A SQL statement must refer to a simple column list or to the entire column list (*).
The statement must not set the read-only flag of the options argument.
Oracle must permit ROWID
references to the selected rows of the query.
Any SQL statement that does not meet these criteria is processed, but the results are not updatable and the Updatable
property of the dynaset returns False
.
This method automatically moves to the first row of the created dynaset.
You can use SQL bind variables in conjunction with the OraParameters
collection.
Examples
This example demonstrates the CreateCustomDynaset
method. Copy and paste this code into the definition section of a form, then press F5.
Sub Form_Load () 'Declare variables Dim OraSession As OraSession Dim OraDatabase As OraDatabase Dim OraDynaset As OraDynaset 'Create the OraSession Object. Set OraSession = CreateObject("OracleInProcServer.XOraSession") 'Create the OraDatabase Object by opening a connection to Oracle. Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&) 'Create the OraDynaset Object using sliceSize as 256,perblock size as 16, no. of 'blocks as 20, fetchLimit as 20,FetchSize as 4096 Set OraDynaset = OraDatabase.CreateCustomDynaset("select empno, " & _ "ename from emp", 0&,256,16,20,20,4096) 'Display the first record. MsgBox "Employee " & OraDynaset.Fields("empno").value & ", #" & _ OraDynaset.Fields("ename").value End Sub
Applies To
Description
Inserts values into the table parameter.
Usage
OraParamArray.Put_Value(value, index)
Arguments
The arguments for the method are:
Arguments | Description |
---|---|
[in ] value | A Variant representing the value to insert. |
[in ] index | An Integer representing the index value of the object. |
Remarks
This method should be used to insert a value before accessing a row in a table. A row does not contain a valid value until a row is assigned a value. Any reference to an unassigned row in the table raises an OLE
Automation
error
.
The value
argument can be an Oracle Database 10g object, such as an OraBLOB
. For Put_Value
, a copy of the object is made at that point in time, and Get_Value
must be accessed to obtain a new object that refers to that index value. For example, if iotype
is ORATYPE_BOTH
and an OraBLOB
obtained from a dynaset is passed in as the input value, Get_Value
needs to be called after the SQL has been executed to obtain the newly updated output value of the ParamaterArray
.
Similar to a dynaset, the object obtained from ParamaterArray
Get_Value
method always refers to the latest value for that ParamaterArray
index. The Visual Basic value Null
can also be passed as a value. The Visual Basic value EMPTY
can be used for BLOB
and CLOB
to indicate an empty LOB, and for OBJECT
, VARRAY
and NESTED
TABLE
to indicate an object whose attributes are all Null
.
When binding to RAW
columns (ServerType
ORATYPE_RAW_BIN
) value should be a byte array.
Applies To
Description
Begins a database transaction within the specified session.
Usage
oraconnection.BeginTrans oradatabase.BeginTrans orasession.BeginTrans
Remarks
After this method has been called, no database transactions are committed until a CommitTrans
is issued. Alternatively, the session can be rolled back using the Rollback
method. If a transaction has already been started, repeated use of the BeginTrans
method causes an error.
If Update
or Delete
methods fail on a given row in a dynaset in a global transaction after you issue a BeginTrans
, be aware that locks remain on those rows on which you called the Update
or Delete
method. These locks persist until you call a CommitTrans
or Rollback
method.
Note: If anOraDatabase object has been enlisted with Microsoft Transaction Server (MTS) and is part of a global MTS transaction, this method has no effect. |
Examples
This example demonstrates the use of the BeginTrans
method to group a set of dynaset edits into a single transaction and uses the Rollback
method to cancel those changes. Copy this code into the definition section of a form. Then, press F5.
Sub Form_Load () 'Declare variables Dim OraSession As OraSession Dim OraDatabase As OraDatabase Dim OraDynaset As OraDynaset Dim fld As OraField 'Create the OraSession Object. Set OraSession = CreateObject("OracleInProcServer.XOraSession") 'Create the OraDatabase Object by opening a connection to Oracle. Set OraDatabase = OraSession. OpenDatabase("ExampleDb", _ "scott/tiger", 0&) 'Create the OraDynaset Object. Set OraDynaset = OraDatabase.CreateDynaset("select * from emp", 0&) 'Start Transaction processing. OraSession.BeginTrans 'Setup a field object to save object references. Set fld = OraDynaset.Fields("sal") 'Traverse until EOF is reached, setting each employees salary to zero Do Until OraDynaset.EOF = True OraDynaset.Edit fld.value = 0 OraDynaset.Update OraDynaset.MoveNext Loop MsgBox "All salaries set to ZERO." 'Currently, the changes have NOT been committed to the database. 'End Transaction processing. Using RollbackTrans 'means the rollback can be canceled in the Validate event. OraSession.Rollback 'MsgBox "Salary changes rolled back." End Sub
This chapter describes the Oracle Objects for OLE Server properties.
For an introduction to Server Objects, see "Oracle Objects for OLE In-Process Automation Server" .
This chapter contains these topics:
Server Properties: A to F
Server Properties: E to L
Server Properties: M to O
Server Properties: P to T
Server Properties: U to Z