Chapter 8. Embedding Perl into PL/SQL

PL/SQL is Oracle’s own programming language. It©’s a powerful procedural language that is tightly integrated with SQL (“PL/SQL” stands for “Procedure Language extension to Structured Query Language”). It offers a full range of datatypes, conditional and sequential control, looping, exception handling, modular code constructs, user-defined datatypes (such as objects), and a lot more. It’s likely that you have a whole raft of PL/SQL programs that you use daily to perform Oracle database administration.

With all of its advantages, PL/SQL has a few limitations as well. There are things PL/SQL programmers want to do that turn out to be impossible, or at least inefficient, to do with PL/SQL alone. As you might suspect, we think Perl is the ideal supplement to PL/SQL. By calling Perl modules from your PL.SQL programs (more accurately, by embedding Perl within PL/SQL), your PL/SQL programs acquire many additional capabilities:

Mailing and the Internet

It is sometimes difficult to email or connect to the Internet from within PL/SQL, but there are hundreds of helpful connectivity options available through Perl.

Encryption

PL/SQL offers very little built-in security, but Perl provides access to many different types of encrypted security systems. (Later in this chapter we’ll show how we use the MD5 message digest algorithm from within PL/SQL via Digest::MD5.)

Operating system commands

Every now and again — perhaps while running complex backup maneuvers ...

Get Perl for Oracle DBAs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.