PATH  WebObjects 4.0 Documentation > ODBCEOAdaptor Reference



ODBCChannel

Inherits From:
EOAdaptorChannel : NSObject

Declared in: ODBCEOAdaptor/ODBCChannel.h


Class Description

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

The features ODBCChannel adds to EOAdaptorChannel are methods for returning the ODBC Statement Handle (HSTMT), and for returning a dictionary-formatted result from SQLTypeInfo().


Method Types

Getting the HSTMT data structure
- odbcStatement
Getting type information
- odbcTypeInfo
Opening and closing a channel
- openChannel
- closeChannel
- isOpen
Modifying rows
- deleteRowsDescribedByQualifier:entity:
- insertRow:forEntity:
Getting schema information
- describeModelWithTableNames:
- describeTableNames
Fetching rows
- selectAttributes:fetchSpecification:lock:entity:
- fetchRowWithZone:
- attributesToFetch
- cancelFetch
- describeResults
- setAttributesToFetch:
- isFetchInProgress
Sending SQL to the server
- evaluateExpression:
Assigning primary keys
- primaryKeyForNewRowWithEntity:

Instance Methods


attributesToFetch

- (NSArray *)attributesToFetch

Overrides the EOAdaptorChannel method attributesToFetch to return the set of attributes to retrieve with fetchRowWithZone:.


cancelFetch

- (void)cancelFetch

Overrides the EOAdaptorChannel method cancelFetch to clear all result sets established by the last selectAttributes:fetchSpecification:lock:entity: or evaluateExpression: message and terminate the current fetch, so that isFetchInProgress returns NO.


closeChannel

- (void)closeChannel

Overrides the EOAdaptorChannel method closeChannel to close the channel so that it can't perform operations with the server. Any fetch in progress is canceled. This method has the side effect of closing the receiver's adaptor context's connection with the database if the receiver is its adaptor context's last open channel.


deleteRowsDescribedByQualifier:entity:

- (unsigned)deleteRowsDescribedByQualifier:(EOQualifier *)qualifier
entity:(EOEntity *)entity

Overrides the EOAdaptorChannel method deleteRowsDescribedByQualifier:entity: to delete the rows described by qualifier and return the number of rows deleted. Raises an exception on failure. Some possible reasons for failure are:


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. Raises an exception if an error occurs.


describeResults

- (NSArray *)describeResults

Overrides the EOAdaptorChannel method describeResults to return an array of EOAttributes describing the properties available in the current result set, as determined by selectAttributes:fetchSpecification:lock:entity: or a statement evaluated by evaluateExpression:. Raises an exception if an error occurs.


describeTableNames

- (NSArray *)describeTableNames

Overrides the EOAdaptorChannel method describeTableNames to read and return an array of table names from the database. This method is used in conjunction with describeModelWithTableNames: to build a default model. Raises an exception if an error occurs.


evaluateExpression:

- (void)evaluateExpression:(EOSQLExpression *)expression

Overrides the EOAdaptorChannel method evaluateExpression: to send expression to the database server for evaluation, beginning a transaction first and committing it after evaluation if a transaction isn't already in progress. Raises an exception if an error occurs.


fetchRowWithZone:

- (NSMutableDictionary *)fetchRowWithZone:(NSZone *)zone

Overrides the EOAdaptorChannel method fetchRowWithZone: to fetch the next row from the result set of the last selectAttributes:fetchSpecification:lock:entity: or evaluateExpression: message sent to the receiver. Returns values for the receiver's attributesToFetch. When there are no more rows in the current result set, this method returns nil, and invokes the delegate method adaptorChannelDidChangeResultSet: if there are more results sets. When there are no more rows or result sets, this method returns nil, ends the fetch, and invokes adaptorChannelDidFinishFetching:. isFetchInProgress returns YES until the fetch is canceled or until this method exhausts all result sets and returns nil. Raises an exception if an error occurs.


insertRow:forEntity:

- (void)insertRow:(NSDictionary *)row forEntity:(EOEntity *)entity

Overrides the EOAdaptorChannel method insertRow:forEntity: to insert the values of row into the table in the database that corresponds to entity. row is an NSDictionary whose keys are attribute names and whose values are the values to insert. Raises an exception on failure. Some possible reasons for failure are:


isFetchInProgress

- (BOOL)isFetchInProgress

Overrides the EOAdaptorChannel method isFetchInProgress to return YES if the receiver is fetching, NO otherwise. An adaptor channel is fetching if:

An adaptor channel stops fetching when there are no more records to fetch or when it's sent a cancelFetch message.


isOpen

- (BOOL)isOpen

Overrides the EOAdaptorChannel method isOpen to return YES if the channel has been opened with openChannel, NO if not.


odbcStatement

- (void *)odbcStatement

Returns the ODBC Statement Handle HSTMT as a void*; you must cast the returned value to HSTMT to work with it.


odbcTypeInfo

- (NSDictionary *)odbcTypeInfo

Returns the result from SQLTypeInfo(), formatted in an NSDictionary ready to incorporate into a model file.


openChannel

- (void)openChannel

Overrides the EOAdaptorChannel method openChannel to put the channel and both its context and adaptor into a state where they are ready to perform database operations. Raises an exception if error occurs.


primaryKeyForNewRowWithEntity:

- (NSDictionary *)primaryKeyForNewRowWithEntity:(EOEntity *)entity

Overrides the EOAdaptorChannel method primaryKeyForNewRowWithEntity: to return a primary key for a new row in the database table that corresponds to entity. If unsuccessful, returns nil.


selectAttributes:fetchSpecification:lock:entity:

- (void)selectAttributes:(NSArray *)attributes
fetchSpecification:(EOFetchSpecification *)fetchSpecification
lock:(BOOL)flag
entity:(EOEntity *)entity

Overrides the EOAdaptorChannel method selectAttributes:fetchSpecification:lock:entity: to select attributes in rows matching the qualifier in fetchSpecification and set the receiver's attributes to fetch. The selected rows compose one or more result sets, each row of which will be returned by subsequent fetchRowWithZone: messages according to fetchSpecification's sort orderings. If flag is YES, the rows are locked if possible so that no other user can modify them (the lock specification in fetchSpecification is ignored). Raises an exception if an error occurs. Some possible reasons for failure are:


setAttributesToFetch:

- (void)setAttributesToFetch:(NSArray *)attributes

Overrides the EOAdaptorChannel method setAttributesToFetch: to change the set of attributes used to describe the fetch data in the middle of a select. This method raises an exception if invoked when there is no fetch in progress.


updateValues:inRowsDescribedByQualifier:entity:

- (unsigned)updateValues:(NSDictionary *)row
inRowsDescribedByQualifier:(EOQualifier *)qualifier
entity:(EOEntity *)entity

Overrides the EOAdaptorChannel method updateValues:inRowsDescribedByQualifier:entity: to update the rows described by qualifier with the values in values. values is an NSDictionary whose keys are attribute names and whose values are the new values for those attributes (the dictionary need only contain entries for the attributes being changed). Returns the number of updated rows. Raises an exception if an error occurs. Some possible reasons for failure are:





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