Oracle9i Data Cartridge Developer's Guide Release 2 (9.2) Part Number A96595-01 |
|
This chapter describes the routines that need to be implemented to define pipelined and parallel table functions in C.
See Also:
Chapter 12 for an overall explanation of pipelined and parallel table functions |
STATIC FUNCTION ODCITableStart(sctx OUT <imptype>, <args>) RETURN NUMBER
ODCITableStart
initializes the scan of a table function.
ODCIConst.Success
on success, ODCIConst.Error
otherwise.
sctx
) and returned to Oracle. The arguments to the table function, specified by the user in the SELECT
statement, are passed in as parameters to this routine.REF CURSOR
arguments of the table function must be declared as SYS_REFCURSOR
type in the declaration of the ODCITableStart
method.MEMBER FUNCTION ODCITableFetch(self IN OUT <imptype>, nrows IN NUMBER, rws OUT <coll-type>) RETURN NUMBER
ODCITableFetch returns the next batch of rows from a table function.
ODCIConst.Success
on success, ODCIConst.Error
otherwise.
ODCITableFetch
is invoked one or more times by Oracle to retrieve all the rows in the collection returned by the table function. The scan context is passed in as a parameter. Typically ODCITableFetch
uses the input scan context and computes the next set of rows to be returned to Oracle. In addition, it may update the scan context accordingly.
Returning more rows in each invocation of fetch()
reduces the number of fetch calls that need to be made and thus improves performance.
Oracle calls ODCITableFetch
repeatedly until all rows in the table function's collection have been returned. When all rows have been returned, ODCITableFetch
should return a null collection.
MEMBER FUNCTION ODCITableClose(self IN <imptype>) RETURN NUMBER
ODCITableClose performs cleanup operations after scanning a table function.
Parameter | Meaning |
---|---|
self (IN) |
The scan context set up by previous scan routine invocation |
ODCIConst.Success
on success, ODCIConst.Error
otherwise.
Oracle invokes ODCITableClose after the last fetch call. The scan context is passed in as a parameter. ODCITableClose then performs any necessary cleanup operations, such as freeing memory.
STATIC FUNCTION ODCITableDescribe(rtype OUT ANYTYPE, <args>) RETURN NUMBER
ODCITableDescribe
returns describe information for a table function whose return type is ANYDATASET
.
Parameter | Meaning |
---|---|
rtype (OUT) |
The |
args (IN) |
The set of zero or more arguments specified by the user for the table function. |
ODCIConst.Success
on success, ODCIConst.Error
otherwise.
Oracle invokes ODCITableDescribe
at query compilation time to retrieve the specific type information.
Note that this interface is applicable only for table functions whose return type is ANYDATASET
. The format of elements within the returned collection is conveyed to Oracle by returning an instance of ANYTYPE
. The ANYTYPE
instance specifies the actual structure of the returned rows in the context of the specific query.
ANYTYPE
provides a datatype to model the metadata of a row--the names and datatypes of all the columns (fields) comprising the row. It also provides a set of PL/SQL and C interfaces for users to construct and access the metadata information. ANYDATASET
, like ANYTYPE
, contains a description of a given type, but ANYDATASET
also contains a set of data instances of that type
See Also:
"Transient and Generic Types" in Chapter 12 for a discussion of |
The following example shows a query on a table function that uses the ANYDATASET
type:
SELECT * FROM TABLE(CAST(AnyBooks('http://.../books.xml') AS ANYDATASET));
At query compilation time, Oracle invokes the ODCITableDescribe
routine. The routine typically uses the user arguments to figure out the nature of the return rows. In this example, ODCITableDescribe
consults the DTD of the XML documents at the specified location to determine the appropriate ANYTYPE
value to return. Each ANYTYPE
instance is constructed by invoking the constructor APIs with this field name and datatype information.
Any arguments of the table function which are not constants are passed to ODCITableDescribe
as NULL
s because their values are not known at compile time.
|
Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. |
|