Download ODMG OQL User Manual
Transcript
4 4.3.13.5 Typing an Expression If e is an expr ession, if c is a t ype n am e, t h en (c)e is an expr ession . Th is asser ts t h at e is an object of class t ype c. If it tu r n s ou t t h at it is n ot t r u e, an except ion is r aised at r u n tim e. Th is is u sefu l t o access a pr oper ty of an object wh ich is statically k n own t o be of a su per class of t h e specified class. Exam ple: select ((Employee) s).salary from Students s where s in (select sec.assistant from Sections sec) Th is r et u r n s t h e set of salar ies of all stu den ts wh o ar e teach in g assist an ts, assu m in g t h at Students an d Sections ar e t h e ext en t s of t h e classes Student an d Section. 4.3.14 Function Call If f is a fu n ct ion n am e, if e1 , e2 , ..., en ar e expr ession s, th en f() and f(e1, e2, ... , en) ar e expr ession s wh ose valu e is t h e valu e r et u r n ed by th e fu n ct ion , or t h e object nil, wh en t h e fu n ct ion does n ot r et u r n an y valu e. Th e fir st for m allows you t o call a fu n ct ion wit h ou t a par am eter , wh ile t h e secon d on e calls a fu n ction with t he par am et er s e1, e2, ..., en. OQL does n ot defin e in wh ich lan gu age t h e body of su ch a fu n ction is wr it t en . Th is feat u r e allows you to sm oot h ly exten d t h e fu n ct ion ality of OQL wit h ou t ch an gin g th e lan gu age. 4.3.15 Scope Rules Th e from par t of a select -fr om -wh er e qu er y in t r odu ces explicit or im plicit var iables t o r an ge over th e filter ed collection s. An exam ple of an explicit var iable is: select ... from Persons p ... wh ile an im plicit declar at ion wou ld be: select ... from Persons ... Th e scope of t h ese var iables r each es all par t s of th e select -fr om -wh er e expr ession in clu din g n ested su b-expr ession s. Th e group by par t of a select -fr om -wh er e-gr ou p_by qu er y in t r odu ces th e n am e partition alon g wit h possible explicit at t r ibu te n am es wh ich ch ar acter ize th e par t ition . These n am es ar e visible in t h e cor r espon din g having an d select par t s, in clu din g n est ed su b-expr ession s wit h in t h ese par t s. 4-26 ODMG OQL User Man u al