logo for asktheoracle.net
Home
AskTheOracle Blog
Oracle Tips & Tricks
Oracle Training
Oracle Tutorials
PL/SQL
SQL
Advanced Tutorials
Performance Tuning
Certification
Oracle 10g
Oracle 11g
Oracle and .Net
Oracle Utilities
Developer Tools
Oracle Questions?
Oracle News
Search This Site
About Us
Disclaimer
Privacy Policy
Contact Us

Subscribe To This Site
XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines
leftimage for asktheoracle.net

PLSQL Tutorial - A Whistle Stop Tour of PL/SQL

This is a short PLSQL tutorial to act as an introduction to Oracle's PL/SQL and is the first in a series of tutorials.

In this PLSQL tutorial we'll answer the following questions:

What is PL/SQL?

Learn the fundamentals in our short video tutorial which shows you how to write a program in PL/SQL to display "Hello World" in about 30 seconds!  


PL/SQL is Oracle's proprietary, block-structured, strongly-typed, procedural programming language for manipulating data and interacting with Oracle databases.

The procedural part is important. PL/SQL provides you with all the things that SQL lacks like user-defined functions, loops, control statements (though SQL does provide some control in the form of the CASE clause, and the DECODE and NVL functions.). In fact the name stands for "Procedural Language extensions to the Structured Query Language".

Overall PL/SQL is a high-level language very similar to Pascal and ADA (from which it is derived). As Pascal was designed as a teaching language, this makes PL/SQL easy to learn and to use and it promotes good programming practice. Although it is still possible to write bad code using PL/SQL, you just have to try that bit harder to do so!

Oracle Tips & Tricks
to SKYROCKET Your Career!

If you're not already a subscriber to Oracle Tips & Tricks you're  missing out on a myriad of tips and techniques to help you become a better, faster, smarter developer. Subscribe now and ignite your career.

PL/SQL has been described as the poor man's object-oriented language, but that was harsh even before the specific object-oriented features were added in Oracle8. PL/SQL is a very powerful and flexible language which, whilst not strictly object-oriented like Java, still has some o-o features, such as encapsulation, data hiding, inheritance, object types etc.

However, not all object-oriented features are available in all versions of PL/SQL The higher the version you're using, the more o-o features are available. Coverage of the object-oriented features has been deferred to a separate PL/SQL tutorial.

What can PL/SQL do?

Or, perhaps more importantly, what can you do with PL/SQL? The answer is plenty.

As hinted at earlier, you can define your own functions which can be embedded in SQL statements in the same way as the built-in functions.

You can also use it to write complete programs to implement business logic, furthermore you can store these programs in the database itself (and take advantage of the extra power of the server) or in Oracle Forms and Reports.

Stored procedures can be invoked from SQL, or other languages such as Java, C, FORTRAN or Visual Basic. Unfortunately, all of these topics are outside the scope of this PLSQL tutorial.

In short there is little that you can't do - as long as you don't need fancy i/o or file handling features. The only language element for displaying information directly to the end-user is the DBMS_OUTPUT package, whilst the (limited) file handling capabilities are provided by the UTL_FILE package. 

That was just a brief overview of the language - this tutorial continues with 

For tips on other languages, see the Complete Coding blog about programming and software development