PATH  WebObjects 4.0 Documentation > SybaseEOAdaptor Reference



SybaseChannelDelegate

Adopted By:
SybaseChannel delegate objects

Declared in: SybaseEOAdaptor/SybaseChannel.h

Protocol Description

SybaseChannel's delegate methods used for processing compute rows and stored procedures give you access to the three types of non-regular rows supported by Sybase: compute rows, return parameters (from a stored procedure), and status from a stored procedure. Because the access layer can only handle regular table rows, the Sybase adaptor channel normally skips non-regular rows. However, you can use the delegate methods to intercept non-regular rows before they are skipped. These delegate methods are sybaseChannel:willFetchAttributes:forRowOfType:withComputeRowId: and sybaseChannel:willReturnRow:ofType:withComputeRowId:. The method sybaseChannel:willFetchAttributes:forRowOfType:withComputeRowId: is invoked when a row is fetched, while sybaseChannel:willReturnRow:ofType:withComputeRowId: is invoked when a row is about to be returned. Based on the type of the row, the delegate can specify the appropriate behavior. This enables you to use data in one of the three non-regular row types and either extract the data from them or use the method describeResults to return an array of attributes that describe the properties available in the current result set. Using describeResults is appropriate if you're not concerned with format-for example, if you're just writing raw data to a report.

Note: The regular rows in the results from a stored procedure must map to the attributes in the corresponding entity, and must be in alphabetical order.

The SybaseChannel adaptor defines the following constants against which you can compare the returned row type:


Instance Methods


sybaseChannel:willFetchAttributes:forRowOfType:withComputeRowId:

- (NSArray *)sybaseChannel: (SybaseChannel *)channel
willFetchAttributes: (NSArray *)attributes
forRowOfType: (SybaseRowType)rowType
withComputeRowId: (int)computeRowId

Invoked whenever a row is fetched. The delegate can return nil, which causes the row to be skipped, or can return a substitute set of attributes that is appropriate for the type of row being fetched. Delegates can have the channel fabricate a set of attributes for the current non-regular row by calling describeResults. See the protocol introduction for a list of defined constants for rowType.

For example, the following implementation checks the row type; if it's a regular row, it simply returns the attributes. If it's not a regular row type, describeResults is used to return an array of attributes that describe the properties available in the current result set. Note that describeResults always describes the current row type.

- (NSArray *)sybaseChannel:(SybaseChannel *)channel
willFetchAttributes:(NSArray *)attributes
forRowOfType:(SybaseRowType)rowType
withComputeRowId:(int)computeRowId
{
if (rowType == SybaseRegularRow)
return attributes;
    
attributes = [(EOAdaptorChannel *) channel describeResults];
return attributes;
}


sybaseChannel:willReturnRow:ofType:withComputeRowId:

- (BOOL)sybaseChannel: (SybaseChannel *)channel
willReturnRow: (NSDictionary *)row
ofType: (SybaseRowType)rowType
withComputeRowId: (int)computeRowId

Invoked once a row has been read from the database and packaged into the dictionary. Delegates can return YES to cause the row to be returned from fetchAttributes:WithZone:, or they can return NO to cause the row to be skipped. See the protocol introduction for a list of defined constants for rowType.

For example, the following implementation checks each row type and uses NSLog() to output a message describing the row's type. In this example all rows are returned, but you could use this template to selectively return or not return rows based on type.

- (BOOL)sybaseChannel:(SybaseChannel *)channel
willReturnRow:(NSDictionary *)row ofType:(SybaseRowType)rowType 
withComputeRowId:(int)computeRowId
{
switch (rowType) {
    case SybaseRegularRow:
        break;
    case SybaseComputeRow:
        NSLog(@"Returning compute row");
        break;
    case SybaseReturnParameterRow:
        NSLog(@"Returning return parameter row");
        break;
    case SybaseReturnStatusRow:
        NSLog(@"Returning return status row");
        break;
}
return YES;
}





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