OracleChannel

Inherits From:
EOAdaptorChannel : NSObject

Declared in: OracleEOAdaptor/OracleChannel.h
OracleEOAdaptor/OracleDescription.h

Class Description

An OracleChannel represents an independent communication channel to the database server its OracleAdaptor is connected to. All of an OracleChannel's operations take place within the context of transactions controlled or tracked by its OracleContext. An OracleContext can manage multiple OracleChannels, and a channel is associated with only one context.

The features OracleChannel adds to EOAdaptorChannel are as follows:

Handling Errors

OracleChannel provides a method for handling errors: raiseOracleError. This method is invoked whenever the channel encounters an error reported by the Oracle server. The methods cursorDataArea, hostDataArea, and logonDataArea are used to retrieve Oracle-specific data structures from the channel and context to determine what error has occurred. The hostDataArea and logonDataArea methods are declared in the OracleContext class.

Generating Primary Keys

Each adaptor provides a database-specific implementation of the method primaryKeyForNewRowWithEntity: for generating primary keys. The OracleChannel's implementation uses sequence objects to provide primary key values. The statement used to create the sequence is:

create sequence table_SEQ

where table is the name of the table for which the adaptor provides primary key values. The adaptor sets the sequence start value to the corresponding table's maximum primary key value plus one.

To use OracleChannel's database-specific primary key generation mechanism, be sure that your database accommodates the adaptor's scheme. To modify your database so that it supports the adaptor's mechanism for generating primary keys, use EOModeler. For more information on this topic, see Enterprise Objects Framework Developer's Guide.

Method Types

Setting channel characteristics
+ oracleTableNamesSQL
+ setOracleTableNamesSQL:
- cursorDataArea
- fetchBufferLength
- setFetchBufferLength:
Returning information from the server
- describeModelWithTableNames:
- describeStoredProceduresForModel:
- describeTableNames
Error handling
- raiseOracleError

Class Methods

oracleTableNamesSQL

+ (NSString *)oracleTableNamesSQL

Returns the SQL statement that will be executed when building a default model.

setOracleTableNamesSQL:

+ (void)setOracleTableNamesSQL:(NSString *)sql

Sets to sql the SQL statement that will be used to return a list of table names from the database. By default, this list is the result of the SQL statement:

SELECT TABLE_NAME FROM USER_TABLES ORDER BY TABLE_NAME

This setting is used by all OracleChannels in an application. You can specify a different SQL statement using the dwrite command, for example:

% dwrite NSGlobalDomain OracleTableNamesSQL "SELECT TABLE_NAME FROM..."

Once you use setOracleTableNamesSQL: to specify a setting, it supersedes values set with the dwrite command.

Instance Methods

cursorDataArea

- (struct cda_def *)cursorDataArea

If the channel is connected, returns an Oracle-specific data structure (cda_def) describing characteristics of the channel. Otherwise, returns NULL. This method is commonly used with the method raiseOracleError to determine why an error occurred.

describeModelWithTableNames:

- (EOModel *)describeModelWithTableNames:(NSArray *)tableNames

Overrides the EOAdaptorChannel method describeModelWithTableNames: to create and return a default model containing entities for the tables specified in tableNames. Assigns the adaptor name and connection dictionary to the new model. This method is typically used in conjunction with describeTableNames and describeStoredProceduresForModel: . Raises an exception if an error occurs.

See also: - describeStoredProceduresForModel: , - describeTableNames

describeStoredProceduresForModel:

- (void)describeStoredProceduresForModel:(EOModel *)model

Overrides the EOAdaptorChannel method describeStoredProceduresForModel: to add stored procedure definitions to model. For every function and stored procedure found in the ALL_OBJECTS view, this method creates a corresponding entry in model's list of stored procedures. Raises an exception if an error occurs.

See also: - describeModelWithTableNames: , - describeTableNames

describeTableNames

- (NSArray *)describeTableNames

Overrides the EOAdaptorChannel method describeTableNames to return an array of the names of all the tables owned by the current user. Uses the SQL defined in EOOracleTableNamesSQL if it exists.

This method is used in conjunction with describeModelWithTableNames: to build a default model.

See also: - describeModelWithTableNames: , - describeStoredProceduresForModel:

fetchBufferLength

- (unsigned)fetchBufferLength

Returns the size, in bytes, of the fetch buffer. The larger the buffer, the more rows can be returned for each round trip to the server.

See also: - setFetchBufferLength:

raiseOracleError

- (void)raiseOracleError

Examines Oracle structures for error flags and raises an exception if one is found. Takes an error code and converts it into an error message. This method is invoked whenever the channel encounters an error reported by the Oracle server. This uses cursorDataArea, hostDataArea, and logonDataArea to retrieve Oracle-specific data structures from the channel and context to determine what error has occurred. (The hostDataArea and logonDataArea methods are declared in the OracleContext class.)

setFetchBufferLength:

- (void)setFetchBufferLength:(unsigned)length

Sets to length the size, in bytes, of the fetch buffer. The larger the buffer, the more rows can be returned for each round trip to the server.

See also: - fetchBufferLength

Copyright © 1997, Apple Computer, Inc. All rights reserved.