home *** CD-ROM | disk | FTP | other *** search
-
- /*
- MultiBinder.h
- A Binder that knows about multiple result sets
-
- MultiBinders are used instead of DBBinders in order to retrieve
- non-rectangular return results from Sybase or other similar stored
- procedures.
-
- MultiBinders only work in the mode where the binder itself creates
- the recordPrototype for the binder. You cannot provide your own
- recordPrototypes for the MultiBinder.
-
- If you know exactly the sequence of properties the stored procedure
- will be returning to you, then:
- 1. Create a List for each [rectangular] result set the stored
- procedure returns. Each List should contain, in the order the
- stored procedure will return them, the attributes returned from
- the database model. Note that the attributes need not, in
- the case of the MultiBinder, be from the same entity.
- 2. Place all these Lists, in the order in which those result
- sets will be returned by the stored procedure, into a temporary
- List. Pass that temporary list as the argument to
- [multiBinder initFromPropertyLists:]. After initializing the binder,
- the temporary list may be freed. The underlying lists created in
- step #1 are now owned by the MultiBinder, and will be freed
- when the MultiBinder is freed.
- 3. Invoke the stored procedure via [multiBinder evaluateString:].
- 4. Repeatedley call [multiBinder setNext]. You can then call
- [multiBinder valueForProperty:] for each property. Use the
- delegate method binderDidChangeResultSet: to find out when you
- cross result set boundaries.
- 5. All result sets have been retrieved when [multiBinder setNext]
- returns nil. Note that you should have received as many calls
- to binderDidChangeResultSet: as there were result sets returned
- from your stored procedure.
-
- If you want to simply receive whatever the stored procedure happens
- to return, either because of your programs' task or because the
- stored procedure conditionally returns different things:
- 1. Pass nil as the argument to [MultiBinder initFromPropertyLists:].
- 2. Repeatedley call [multiBinder setNext]. You should interrogate
- the binder via [multiBinder getCurrentProperies:] to get the
- new list of properties whenever the delegate method
- binderDidChangeResultSet: is called. DO NOT call getProperties:.
- 3. All rows of all result sets are retrieved when
- [multiBinder setNext] returns nil.
-
- */
-
- #import <dbkit/dbkit.h>
-
- @interface MultiBinder:DBBinder
- {
- unsigned int currentResultSet; /* index into the list of lists */
- List *propListList; /* a list of property lists for the result sets */
- }
-
- - initFromPropertyLists:(List *)propLists; /* copies subsidiary lists out of propLists */
- - (unsigned int)currentResultSet; /* returns the index of the current result set */
- - (List *)getCurrentProperties:(List *)aList; /* fills aList with the current properties */
-
- @end
-
- @interface Object (MultiBinderDelegateMethods)
- - binderWillChangeResultSet:binder; /* called before changing result sets */
- - binderDidChangeResultSet:binder; /* called before fetching from a new result set */
- @end
-
- @interface DBBinder (MultiBinderMethods)
- - (List *)getCurrentProperties:(List *)aList;
- @end
-
-