Type to start searching...
The script to execute when this read mapping is triggered.
In this script, variables named after the tokens in the where clause pattern will be defined. See expr-case for more details.
Additionally, the following variables are defined for all read mapping cases:
class: The class on which the read was executed.
attributes: The read clause attributes list, after dependencies have been resolved, and security clauses, locking attributes, and type code attributes have been added.
where: The where clause that matched the where clause pattern. This where clause is the normalized where clause that is generated by the framework, and will likely differ from the where argument to Object'read.
orderBy: The order by expression.
count: See Object'read.
offset: See Object'read.
xlock: See Object'read.
associations: List of attributes being read homogeneously. It is a subset of "attributes".
properties: An instance of PropertyHolder that contains the properties from the .connections file for the current fragment.
This script returns a transfer object or transfer objects that contain the data for the instances that were read. To return multiple transfer objects, this script may return a collection, a list, an iterator, or a generator function. Returning () means that no instances were read.
A generator function is a function of a single argument; the argument is a special function called "yield". The yield function takes a single argument which is what the generator's return value will be. However, the yield function remembers from what point in the generator it was invoked, and the next time the generator is invoked it continues execution on the statement after yield.
For example, the following generator returns the values of tobj1, tobj2, tobj3, tobj4, and tobj5 in sequence:
(lambda (yield)
(yield tobj1)
(yield tobj2)
(for-each
yield
`(,tobj3 ,tobj4 ,tobj5)
)
)
(set! connection (open-connection))
(set! resultCursor (connection'getResults ...some query...))
; return:
(lambda (yield)
(let nextResult ()
(define result (resultCursor'getNext))
(unless (null? result)
(yield result)
(nextResult)
)
)
)
In the preceeding example, the close script would execute (resultCursor'close) and (connection'close).
The transfer objects must have a value for every primitive attribute in the list of attributes being read. Non-primitive attributes have a value only if that attribute has the association's foreign key; in this case the value is an OID. If the attribute is read homogeneously, then the value is a transfer object or collection of transfer objects.
Additionally, the following special attributes must be set on the transfer object:
:oid: Set to the OID of the instance read.
:class: Set to the name of the class of the instance read. This can be (class'name), or it can be the name of one of the derived classes of class.
If an orderBy expression is specified, (sort-by orderBy) may be used to construct a comparison function for ordering the results.
language : schemeLanguageType
The scripting language for this element.
The language defaults to scheme.Valid values based on“languageType”. | |
---|---|
scheme |
scheme scripting language |