Download ODMG OQL User Manual
Transcript
4 Th is r et u r n s t h e set con t ain in g 1,2,3. 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 t im e. Th is is u sefu l to access a pr oper t y of an object wh ich is st at ically 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 t s wh o ar e teach in g assist an t s, assu m in g th at Students an d Sections ar e th e exten ts 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, t h en f() and f(e1, e2, ... , en) ar e expr ession s wh ose valu e is th e valu e r et u r n ed by t h e fu n ct ion , or t h e object nil, wh en t h e fu n ct ion does n ot r etu r n an y valu e. Th e fir st for m allows you to call a fu n ct ion wit h ou t a par am et er , wh ile t h e secon d on e calls a fu n ct ion wit h t h e 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 ct ion is wr it t en . Th is feat u r e allows you t o sm ooth ly ext en d t h e fu n ct ion alit y of OQL wit h ou t ch an gin g t h 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 t h e filt er 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 t h e select -fr om -wh er e expr ession in clu din g n est ed su b-expr ession s. 80 ODM G OQL User Man u al