11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER <strong>11</strong> ■ APPLICATION DEVELOPMENT 455Generalized InvocationIn prior versions of PL/SQL if you wanted to call an overridden method of a supertype from oneof its subtypes, you would have to create a static method in the supertype and create an overridablewrapper member subprogram that called that static method. Within the subtypes, youwould call the static member as needed. Here is an example of this idiom:CREATE OR REPLACE TYPE SUP_T AS OBJECT(...STATIC PROCEDURE super_init,MEMBER PROCEDURE init)NOT FINAL;CREATE OR REPLACE TYPE BODY SUP_T ASSTATIC PROCEDURE super_init ISBEGIN-- actual init code...END;MEMBER PROCEDURE init ISBEGIN-- the wrapper procedure...super_init;END;END;CREATE OR REPLACE TYPE SUB_T UNDER SUP_T(...OVERRIDING MEMBER PROCEDURE init)CREATE OR REPLACE TYPE BODY SUB_T ASOVERRIDING MEMBER PROCDURE init ISBEGINsuper_init;...END;END;Although this works, the programmer would much rather cast SELF to the correct supertypeand call the method directly. With <strong>Oracle</strong> <strong>Database</strong> <strong>11</strong>g, this functionality has been addedto PL/SQL. For the previous example, the syntax for calling init() in SUP_T from SUB_T is as follows:(SELF AS SUP_T).init();or,init(SELF AS SUP_T);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!