preface_4.htm
In ORDBMS, Object-Relational Database Management System, the user defined objects extended an huge advantage over it's predecessor relational type of DBMS.
Object Types:

Object type is composite data type defined by the user, which would exist as a whole only, life cycles of the  items are tied together . An instance of the Object Type is called as Object.
An object is created with two major components, namely data-attributes and functions / methods. The data attributes would hold the data, and the procedures or functions would perform the operations as directed by the users.

These functions or procedures are usually created with  proprietary language like PL/SQL (Oracle)  , PLPGSQL (PostsqlSQL) or other open/gl languages like c/c++, java , python etc

Oracle Type objects
  • CREATE TYPE emp_type AS OBJECT ( fname varcahr(20),
CREATE TYPE ref: Oracle Data-Stream   statements_8001.htm

In Oracle RDBMS, the statement "CREATE TYPE"  is used  to create a SQL-Object-Type (both in Oracle and PostgreSQL),  a named varying array (varray) of Oracle, a nested table type, or an incomplete object type.

 You can create object types with the CREATE TYPE and the CREATE TYPE BODY statements. The CREATE TYPE statement specifies the name of the object type, its attributes, methods, and other properties. The CREATE TYPE BODY statement contains the code for the methods that implement the type.
 

a) Creating a TYPE with DATA ATTRIBUTE only
CREATE OR REPLACE TYPE emp_typ AS OBJECT (
fname VARCHAR2(30 char),
lname VARCHAR(10)
);
/

b)Creating type with data-type, and methods
CREATE TYPE person_typ AS OBJECT (
eid NUMBER,
fname VARCHAR2(20),
lname VARCHAR2(25),
job VARCHAR2(25),
phone VARCHAR2(20),
MAP MEMBER FUNCTION emp_id RETURN NUMBER,
MEMBER PROCEDURE empinfo_details ( SELF IN OUT NOCOPY person_typ ));
/


Notes:

Map OR Order: to compare two objects

You don't need to use MAP for procedures. If you create an object type for which the type specification declares only attributes but no methods, then you need not specify a type body. In Oracle MAP or ORDER protocol is used to compare the values of two objects during IN or OUT operation. MAP returns the relative position of an instance and compare the scalar data , you can only implement MAP or ORDER, the requirements of these two are optional and not  REQUIRED.


IN OUT:

Oracle has two protocols of passing data as  OUT and IN OUT parameters in a PL/SQL code block. Using NOCOPY  in the attributes, signals the compiler that no temporary buffer has to be allocated, and  no forward or backward data operation was intended. (ref:2)

In a method we often use SELF  qualifier, meaning that this method intends to pass a reference to object.

 

Accessing with php

SELECT e.info.eid, e.info.fname, e.info.lname,e.info.job, e.info.address, e.hire_date FROM empt2_tbl e

http://docs.oracle.com/cd/B12037_01/appdev.101/b10800/dciobjtypes.htm
Oracle  introduced "REF CURSOR" with version 7.3 to allow all the recordsets to be returned to the caller from stored procedures and function. Oracle 9i provided an enhancement, to use inbuilt "SYS_REFFCURSOR";
 
object comparison
MAP MEMBER FUNCTION DataStreamToInt return integer is 
      c integer := id; 
      begin return c; end;