home *** CD-ROM | disk | FTP | other *** search
- // OracleColumn.h
- // Copyright (c) 1994, NeXT Software, Inc. All rights reserved.
-
- #import <EOAccess/EOAccess.h>
-
- @class OracleChannel;
-
- // This class is used internally by the Oracle adaptor to maintain the state
- // of the various column buffers which are needed to fetch data.
-
- // These are the codes for the external (in the client) Oracle data types.
- // OracleClientTypes specify how OCI should convert the data from the rdbms
- // into a form that can be consumed by the adaptor, or to describe the format
- // of of data passed into OCI by the adaptor. Not all of these are used by
- // the current implementation, but are included here for completeness.
-
- typedef enum {
- OciVARCHAR2 = 1,
- OciNUMBER = 2,
- OciINTEGER = 3,
- OciFLOAT = 4,
- OciSTRING = 5,
- OciVARNUM = 6,
- OciPACKED = 7,
- OciLONG = 8,
- OciVARCHAR = 9,
- OciROWID = 11,
- OciDATE = 12,
- OciVARRAW = 15,
- OciRAW = 23,
- OciLONGRAW = 24,
- OciUNSIGNED = 68,
- OciDISPLAY = 91,
- OciLONGVARCHAR = 94,
- OciLONGVARRAW = 95,
- OciCHAR = 96,
- OciCHARZ = 97,
- OciREFCURSOR = 102,
- OciMLSLABEL = 106
- } OracleClientType;
-
- @class OracleChannel;
-
- // This is the abstract class from which all column types descend. It
- // implements the various class methods, but subclasses must implement all of
- // the instance methods.
-
- @interface OracleColumn:NSObject
-
- + (EOAttribute *)attributeWithName:(NSString *)name
- columnName:(NSString *)columnName externalType:(NSString *)dbType
- externalLength:(int)dbLength precision:(int)precision scale:(int)scale
- nullable:(BOOL)nullable;
- // Builds an EOAttribute based on the standard set of information
- // available in Oracle v7 about database columns. This is called from
- // attributeAtPosition:cursor: and by the describe routines.
-
- + (EOAttribute *)attributeAtPosition:(int)position cursor:(struct cda_def *)cda;
- // This uses odescr() to build an attribute for the item at position in
- // the select list. It can only by called after oparse() and before
- // oexec(). Position indices start at 0.
-
- + (NSString *)nameForOracleServerType:(int)type;
- // Return a name for the specified Oracle Server Datatype (VARCHAR2,
- // NUMBER, LONG, etc.)
-
- + (NSString *)decimalSeparator;
- + (void)setDecimalSeparator:(NSString *)separator;
- // These two methods allow users running against Oracle databases running in locales
- // different from their client to pass values to the server correctly (bind variables
- // for SQL and PL/SQL statements). Data fetched from the server is fetch in Oracle's
- // binary number representation and converted to decimal numbers, and thus avoids
- // the separator issue.
- // This behavior can also be controled via the "EOOracleDecimalSeparator" user default
-
- - initWithAttribute:(EOAttribute *)attribute channel:(OracleChannel *)channel;
- // This is the designated initializer for all OracleColumns.
-
- - (int)columnLength;
- // The length of a single element of the column type.
-
- - (EOAttribute *)attribute;
- // This is a simple access for the _attribute ivar
-
- - (void)defineWithCursor:(struct cda_def *)cda selectPosition:(unsigned)index
- rowCapacity:(unsigned)capacity;
- // Called by the channel to allow the column to define the output buffers.
-
- - (void)bindToVariableNamed:(NSString *)name withCda:(struct cda_def *)cda;
- // Bind the column to an oracle bind variable with the specified name
-
- - (BOOL)canUseArrayFetching;
- // If all of the OracleColumns in a select list return YES, then the
- // channel will use array fetching to get more than one row at a time from
- // the server.
-
- - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
- // This is the method which gets called to actually fetch data for a column
- // Returns a *retained* object (caller must release).
-
- - (void)takeInputValue:(id)value;
- // Set the input value for a bind variable
- // Used when passing IN bind variables
-
- @end
-
-
- // This is the column class from which all primitive column types descend.
- // It implements the basics of talking to the client library to get data out
- // of the database.
-
- @interface OracleConcreteColumn:OracleColumn
- {
- NSString *_attributeName;
- OracleChannel *_channel;
- EOAttribute *_attribute;
- signed short *_indicator;
- unsigned short *_returnLength;
- unsigned short *_returnCode;
- unsigned char *_columnBuffer;
- NSStringEncoding _encoding;
- EOAdaptorValueType _adaptorValueType;
-
- OracleClientType _clientType;
- int _columnLength;
- }
-
- - initWithAttribute:(EOAttribute *)attribute channel:(OracleChannel *)channel;
- // Each column subclass must set _clientType and _columnLength in their
- // initWithAttribute: method.
-
- - (void)defineWithCursor:(struct cda_def *)cda selectPosition:(unsigned)index
- rowCapacity:(unsigned)capacity;
- // Does the odefin () to set up the buffers for fetching data and getting
- // the various return codes. The instance variables _clientType and
- // _columnLength must be set up by the subclasses before getting here.
-
- - (BOOL)canUseArrayFetching;
- // By default this returns YES. Subclasses should return NO if they cannot
- // use Oracle's array fetching API (if they need to use oflng ()).
- @end
-
- // These are the various kinds of primitive Oracle column buffers...
-
- @interface OracleByteColumn:OracleConcreteColumn
- - initWithAttribute:(EOAttribute *)attribute channel:(OracleChannel *)channel;
- - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
- @end
-
- @interface OracleNumberColumn:OracleConcreteColumn
- - initWithAttribute:(EOAttribute *)attribute channel:(OracleChannel *)channel;
- - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
- @end
-
- @interface OracleDataColumn:OracleConcreteColumn
- - initWithAttribute:(EOAttribute *)attribute channel:(OracleChannel *)channel;
- - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
- @end
-
- @interface OracleDateColumn:OracleConcreteColumn
- - initWithAttribute:(EOAttribute *)attribute channel:(OracleChannel *)channel;
- - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
- @end
-
- // While all the other kinds of columns are based on the value they are going
- // to create, the OracleLongColumn is based on the value it has to fetch.
- // Getting a LONG or LONG RAW column out of the database requires some special
- // work. It can return an NSString or an NSData.
-
- @interface OracleLongColumn:OracleConcreteColumn
- {
- struct cda_def *_cda;
- int _position;
- BOOL _objectIsData;
- NSString *_variableName;
- }
- - initWithAttribute:(EOAttribute *)attribute channel:(OracleChannel *)channel;
- - (BOOL)canUseArrayFetching;
- - (void)defineWithCursor:(struct cda_def *)cda selectPosition:(unsigned)position
- rowCapacity:(unsigned)capacity;
- - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
- @end
-
- @interface OracleRefCursorColumn:OracleConcreteColumn
- {
- }
- - (struct cda_def *)cursorFromColumn;
- @end
-
-