Content deleted Content added
→The PL/SQL: ce |
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5 |
||
(29 intermediate revisions by 19 users not shown) | |||
Line 1:
'''Object-PL/SQL''' ('''[[Object-oriented programming|Object]]-Procedural Language/[[Structured Query Language]]''' or simply '''O-PL/SQL''') is a methodology of using the [[Oracle Corporation]]'s [[Procedural programming|procedural]] extension [[programming language|language]] for [[SQL]] and the [[Oracle Database|Oracle relational database]].<ref name="CITDK">{{cite web|url=http://www.cit.dk/cot/reports/reports/Case4/18/cot-4-18.pdf|title=Experiences with Object Oriented Development in PL/SQL|author=Lassan, Alan R.
Although PL/SQL's general [[Syntax (programming languages)|syntax]] formerly used to resemble that of [[Ada (programming language)|Ada]] or [[Pascal (programming language)|Pascal]], there were many improvements that mainly include the ''Java embedding code''<ref name="STKOVER">{{cite web|url=
The mixing and embedding of [[Database trigger|triggers]] and [[stored procedure]]s was one of the breakthrough points up to support the use of [[PL/SQL]] in a ''OO'' paradigm.<ref name="SAMS">Benett, 2002:144</ref> The inclusion in the SQL syntax of statements such as
== Autonomy, notoriety and importance of O-PL/SQL ==
The O-PSL/SQL isn't
== A confusing of ''objects'' ==
There can be confusion of the notions of ''object of DBMS'' and of ''class object''. This is very important as we live with both significances in one language. It's necessary to identify when the documentation refers to an ''object'' as one of the two definitions.
''Database objects'' are concepts that refer to [[Relational model|relational]] or sequential databases and persist being valid in new models. ''Tables'', ''triggers'', ''columns'', ''indexes'' are examples of database objects,<ref name="TOP10">{{cite web|url=http://www.codeproject.com/Articles/43629/Top-10-steps-to-optimize-data-access-in-SQL-Server|title=Optimize Database Files and Apply Partitioning|author=Shubho, Al-Farooque|date=8 November 2009|publisher=The Code Project|
== The PL/SQL ==
{{Main article|PL/SQL}}
PL/SQL is the extended SQL language used by [[Oracle Database]].
PL/SQL is available in Oracle Database (since version 7), [[TimesTen|TimesTen in-memory database]] (since version 11.2.1), and [[IBM
O-PL/SQL allows the definition of classes and instantiating these as objects,
▲us creating user-defined datatypes as writing constructors, beyond using Java in stored procedures and triggers.
== Examples of uses of syntax of O-PL/SQL ==
Here is a small set of examples of O-PL/SQL syntax, extracted from the official documentation<ref name="ORADOC">{{cite web|url=http://docs.oracle.com/|title=Oracle Documentatio|publisher=Oracle|
A simple example of object-oriented PL/SQL<ref>{{cite web|url=http://www.adp-gmbh.ch/ora/plsql/oo/example_1.html|title=Object Oriented Oracle, example 1|publisher=René Nyffenegger's collection of things on the web|accessdate=19 April 2012}}</ref><source lang="SQL">▼
▲A simple example of object-oriented PL/SQL<ref>{{cite web|url=http://www.adp-gmbh.ch/ora/plsql/oo/example_1.html|title=Object Oriented Oracle, example 1|publisher=René Nyffenegger's collection of things on the web|
<syntaxhighlight lang="plpgsql">
create or replace type base_type as object (
a number,
Line 36 ⟶ 33:
member procedure proc (n number)
) instantiable not final;
/</
Now, the type's implementation is created. The implementation defines how the type's functions, procedures and how explicit constructors behave:<
create or replace type body base_type as
constructor function base_type return self as result is
Line 55 ⟶ 52:
end proc;
end;
/</
We're ready to derive from base_type. The keyword for deriving is under. The derived type defines a new attribute (named: m) and overrides func.<
create or replace type deriv_type under base_type (
m number,
overriding member function func return number
);
/</
As is the case with base types, the overridden methods in the derived type must be implemented:
<syntaxhighlight lang="plpgsql">
create or replace type body deriv_type as
overriding member function func return number is
Line 69 ⟶ 67:
end;
end;
/</
The created types can be
< declare
b1 base_type :=base_type();
Line 84 ⟶ 83:
dbms_output.put_line(d2.func);
end;
/</
Results
The created types have become real types and can be used in tables:
<syntaxhighlight lang="plpgsql">
create table table_base (
b base_type
Line 103:
/
select t.b.func() from table_base t;
</syntaxhighlight>
Results:
<
select avg(t.b.func()) from table_base t;
</syntaxhighlight>
Result:
Another example of stored procedure in Java embedded in Oracle Documentation<ref name="ORA2">{{cite web|url=http://docs.oracle.com/cd/B19306_01/java.102/b14187/chthree.htm#CACFGDCI|title=Calling Java Methods in Oracle Database|publisher=Oracle|accessdate=20 April 2012}}</ref>▼
== Bibliography ==▼
* {{cite book|url=http://books.google.com.br/books?id=1RwFA-vlwX8C&pg=PA144&lpg=PA144&dq=mixing+java+in+pl/sql+procedures+and+triggers&source=bl&ots=Vw7l1H7TUe&sig=bykIRLXpPkVPYucWr3fJhpYjzfY&hl=pt-BR&sa=X&ei=L2WMT5ukDYio8gST1JHFCQ&ved=0CCMQ6AEwAA#v=onepage&q=mixing%20java%20in%20pl%2Fsql%20procedures%20and%20triggers&f=false|last=Bennett|first=Mathew|title=Programming Oracle Developer|edition=1|place=Indianapolis|publisher=Sams|year=2002|pages=348|isbn=0672321106}}▼
* {{cite book|url=http://books.google.com.br/books?id=FqUKI3MSuHYC&printsec=frontcover&hl=pt-BR&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false|last=Bales|first=Donals|title=PL/SQL from Novice to Professional|edition=1|place=New York|publisher=Apress|year=2007|isbn=10590598822|pages=469}}▼
* {{cite book|url=http://my.safaribooksonline.com/book/databases/oracle-pl-sql/9780596805401|title=Oracle PL/SQL Programming|last=Feuerstein|first=Steven|last2=Pribyl|first2=Bill|place=Sebastopol|publisher=O'Reilly Media, Inc.|year=2009|pages=978-0-596-51446-4|isbn=9780596514464|chapter=26}}▼
*{{cite book|url=http://218.92.71.5:1085/trebook/book/book36/2009986047703.pdf|last=Rahayu|first=Wenny|last2=taniar|first2=David|last3=Pardede|first3=Eric|title=Object-Oriented Oracle|place=Hershey|publisher=IRM Press|year=2006|pages=345|isbn=1591406080}}▼
==See also==
* [[Relational database management system]]
Line 127 ⟶ 117:
* [[Transact-SQL]]
* [[Database management system]]
▲== Bibliography ==
▲* {{cite book|url=
▲* {{cite book|url=
▲* {{cite book|chapter-url=http://my.safaribooksonline.com/book/databases/oracle-pl-sql/9780596805401|title=Oracle PL/SQL Programming|
▲*{{cite book|url=http://218.92.71.5:1085/trebook/book/book36/2009986047703.pdf|
==References==
Line 132 ⟶ 127:
== External sources ==
* [https://web.archive.org/web/20120917012254/http://elearning.algonquincollege.com/coursemat/dat2355d/oracle-oo.html Examples of O-Pl/SQL]
▲* Another example of stored procedure in Java embedded in Oracle Documentation
<!-- NOTE
This is not the place for links to each and every website that may be helpful
|