Quick Search:
 
 The Oracle PL/SQL ORDER Method      [Return To Index] Jump to:  

Term: ORDER

Definition:
In Oracle PL/SLQ,, the ORDER method is one of the member methods used in the Oracle Object Relational Model to order variables of an object type. It compares the values of two objects based on criteria you specify. One of these objects is SELF while the other one is a parameterized object belonging to the same object type. Based on a comparative condition it returns numeric values -1 (less than), 0 (equal), or +1 (greater than).

Do not confuse ORDER with ORDER_BY; they are completely different terms with different meanings and applications.

Example Syntax:

ORDER MEMBER FUNCTION [METHOD NAME] ( [TYPE PARAMETER] )


Example Usage:

CREATE OR REPLACE TYPE TYP_ORD AS OBJECT (
L_NUM1 NUMBER,
L_NUM2 NUMBER,
ORDER MEMBER FUNCTION SORT (P TYP_ORD) RETURN INTEGER );
/

CREATE OR REPLACE TYPE BODY TYP_ORD AS
ORDER MEMBER FUNCTION SORT(P TYP_ORD) RETURN INTEGER IS
BEGIN
IF L_NUM1 < P.L_NUM1 THEN
RETURN -1;
ELSIF L_NUM1 > P.L_NUM1 THEN
RETURN 1;
ELSE
RETURN 0;
END IF;
END;
END;
/

Related Code Snippets:
  • ORDER BY Clause - The ORDER BY clause is used by, and is the last clause of, a SELECT statement.
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org