Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
1 Object methods Database system Database management system Database SQL object methods External SQL object methods 2 Use of object methods Table with object collection Virtual relational table Table() Object view Method4 Method5 Method6 select … from … where … Method1 Method2 Method3 3 Types of object methods Object methods (also known as subprograms) are functions or procedures that you can declare in an object type definition to implement behavior that you want objects of that type to perform. The general kinds of methods that can be declared in a type definition are: 1. Member methods. Using member methods, you can provide access to the data of an object, and otherwise define operations that an application performs on the data. To perform an operation, the application calls the appropriate method on the appropriate object. 1) comparison methods: a) MAP MEMBER function; b) ORDER MEMBER function. 2) non-comparison member methods: a) MEMBER function; b) MEMBER procedure. Member methods have a built-in parameter named SELF that denotes the object instance currently invoking the method. SELF can be explicitly declared, but that is not necessary. It is simpler to write member methods that reference the attributes and methods of SELF implicitly without the SELF qualifier. 2. Static methods. Static methods compare object instances and perform operations that do not use the data of any particular object, but, instead, are global to an object type. 3. Constructor methods. A default constructor method is implicitly defined for every object type, unless it is overwritten with a user-defined constructor. A constructor method is called on a type to construct or create an object instance of the type. 4 Object methods 1. Constructor method. 2. MAP Member method. 3. ORDER Member method. 4. MEMBER method. 5. STATIC method. a) MAP MEMBER method SELECT ... FROM ... WHERE ... ORDER BY ... SELF pbjekti b) ORDER MEMBER method c) OSQL MEMBER method 5 Subprograms in database Subprograms can be written in: 1) PL/SQL language; 2) virtually in any other programming language. Methods written in PL/SQL or Java are stored in the database. Methods written in other languages, such as C, are stored externally. 6 Guidelines for comparison methods You can declare: 1) a Map Member method; 2) an Order Member method (but not both). For either method type, you can compare objects using SQL statements and PL/SQL procedural statements. However, if you do not declare one of these methods, you can only compare objects in SQL statements, and only for equality or inequality. Two objects of the same type are considered equal only if the values of their corresponding attributes are equal. When sorting or merging a large number of objects, use a map method, which maps all the objects into scalars, then sorts the scalars. An order method is less efficient because it must be called repeatedly (it can compare only two objects at a time). a) MAP MEMBER method SELECT ... FROM ... WHERE ... ORDER BY ... SELF objects b) ORDER MEMBER method SELF objects 7 Comparison methods in type hierarchies In a type hierarchy, if the root type (supertype) does not specify a map or an order method, neither can the subtypes. If the root type specifies a map method, any of its subtypes can override it. If the root type does not specify a map method, no subtype can specify one either. Only the root type can define an order method. If the root type does not define one, its subtypes cannot add one. 8 Definition of object types 1) specification create or replace type ... 2) body create or replace type body ... create or replace type SCHEMA.TYPE as object( parameterdata_type, parameterdata_TYPE, …, MAP Member FUNCTION ..., ORDER Member FUNCTION ..., MEMBER ..., STATIC ...);