home *** CD-ROM | disk | FTP | other *** search
- /*
- ODBCChannel.h
- Copyright (c) 1996, NeXT Software, Inc.
- All rights reserved.
- */
-
- #import <EOAccess/EOAccess.h>
-
- @interface ODBCChannel : EOAdaptorChannel
- {
- void *_statement; // HSTMT
- NSArray* _attributes; // attributes for current expression
- NSMutableArray *_selectedColumns; // columns for selected attributes
- unsigned _rowsProcessedCount; // number of rows processed thus far
- struct {
- unsigned int beganTransaction:1;
- unsigned int fetchInProgress:1;
- unsigned int :0;
- } _flags;
- }
-
- - initWithAdaptorContext:(EOAdaptorContext *)context;
- // designated initializer. The channel expect an ODBC context.
-
- - (BOOL)isOpen;
- // Returns YES if the channel has been opened with -openChannel,
- // NO if not.
-
- - (void)openChannel;
- // This method puts 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.
-
- - (void)closeChannel;
- // This method disconnects the channel, disconnects the channel's context
- // if the context has no other channels open, and then disconnects the
- // adaptor if it has no additional contexts open.
-
- - (void)insertRow:(NSDictionary *)row forEntity:(EOEntity *)entity;
- // Inserts the attributes of row into the database. row is an
- // NSDictionary whose keys are attribute names and whose values are the
- // values that will be inserted. Raises an exception if error occurs.
-
- - (unsigned)updateValues:(NSDictionary *)row inRowsDescribedByQualifier:(EOQualifier *)qualifier entity:(EOEntity *)entity;
- // Updates the row described by qualifier so that its values are equal to
- // those in the values dictionary. The values dictionary contains a set
- // of attribute name/value pairs. Returns the number of rows affected by
- // this method. This method may raise an exception if an error occurs.
-
- - (unsigned)deleteRowsDescribedByQualifier:(EOQualifier *)qualifier entity:(EOEntity *)entity;
- // Deletes the rows described by the qualifier. Returns the number of rows
- // affected by this method. This method may raise an exception if an error
- // occurs
-
- - (void)selectAttributes:(NSArray *)attributes fetchSpecification:(EOFetchSpecification *)fetchSpec lock:(BOOL)yn entity:(EOEntity *)entity;
- // Selects the given attributes in rows matching the qualifier. The
- // selected rows compose one result set, each row of which will
- // be returned by subsequent -fetchRowWithZone: messages according
- // to the given fetchOrder (see EOSortOrdering.h). If flag is YES,
- // the rows are locked if possible so that no other user can modify them.
- // This methods may raise an exception if an error occurs.
-
- - (void)evaluateExpression:(EOSQLExpression *)expression;
- // Sends expression to the database server for evaluation. This methods
- // may raise an exception if an error occurs.
-
- - (BOOL)isFetchInProgress;
- // Returns YES if the adaptor channel is fetching, NO otherwise. An
- // adaptor channel is fetching if it's been sent a successful
- // -selectAttributes:... message, or if an expression sent through
- // -evaluateExpression: resulted in a select. An adaptor channel stops
- // fetching when there are no more records to fetch or when it's sent
- // a -cancelFetch message
-
- - (NSArray *)describeResults;
- // Returns an array of attributes describing the properties available in
- // the current result set, as determined by -selectAttributes:... or a
- // select statement evaluated by -evaluateExpression:.
- // This methods may raise an exception if an error occurs
-
- - (NSMutableDictionary *)fetchRowWithZone:(NSZone *)zone;
- // Fetches the next row from the result set of the last
- // -selectAttributes:... message and returns values for the attribute
- // names in attributes. 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 -adaptorDidFinishFetching:.
- // -isFetchInProgress returns YES until the fetch is cancelled or until
- // this method exhausts all result sets and returns nil.
- // This methods may raise an exception if an error occurs.
-
- - (void)setAttributesToFetch:(NSArray *)attributes;
- // Allows the user to change the set of attributes used to describe the
- // fetch data in the middle of a select. This method
- // raises if invoked when there is no fetch in progress.
-
- - (NSArray *)attributesToFetch;
- // Returns the set of attributes used by the adaptor for a particular
- // fetch.
-
- - (void)cancelFetch;
- // Clears the result set created by the last selectAttributes:...
- // message, and terminates the current fetch, so that
- // -isFetchInProgress returns NO.
-
- - (NSDictionary *)primaryKeyForNewRowWithEntity:(EOEntity *)entity;
- // try to returns a new primary key.
- // Otherwise, returns nil.
-
- - (NSArray *)describeTableNames;
- // Reads and returns an array of table names from the database. This
- // method in conjunction with describeModelWithTableNames: is used for
- // building a default model in EOModeler. This methods may raise an
- // exception if an error occurs
-
- - (EOModel *)describeModelWithTableNames:(NSArray *)tableNames;
- // Constructs a default model out of the database's meta data. It also
- // put the adaptor name and connection dictionary in the new model.
- // This methods may raise an exception if an error occurs.
-
- // ODBC specific
- - (void *)odbcStatement; // HSTMT
- - (NSDictionary *)odbcTypeInfo;
- // Returns the result for SQLTypeInfo, nicely formatted in a dictionary
- // ready to incorporate to a model file. Called from +getTypeInfoForModel
- // on the ODBCAdaptor.
-
- @end
-