Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Programming PL SQL.doc
Скачиваний:
3
Добавлен:
01.07.2025
Размер:
5 Мб
Скачать
☆

1.2.3 Improved Execution Authority and Transaction Integrity

An even more fundamental issue than portability was execution authority. The RDBMS and the SQL language give you the capability to tightly control access to, and changes in, any particular database table. For example, with the GRANT command you can make sure that only certain roles and users have the ability to perform an UPDATE on a given table. On the other hand, this GRANT statement can't ensure that the full set of UPDATEs performed by a user or application is done correctly. In other words, the database can't guarantee the integrity of a transaction that spans more than one table, as is common with most business transactions.

The PL/SQL language was intended by Oracle to provide tight control and management over logical transactions. One way that PL/SQL does this is with implementation of execution authority. Instead of granting to a role or user the authority to update a table, you grant privileges only to execute a procedure, which controls and provides access to the underlying data structures. The procedure is owned by a separate Oracle RDBMS account, which, in turn, is granted the actual update privileges on those tables needed to perform the transaction. The procedure therefore becomes the "gatekeeper" for the transaction. The only way that a program (whether it's an Oracle Forms application or a Pro*C executable) can execute the transfer is through the procedure. In this way, transaction integrity is guaranteed.

1.2.4 Humble Beginnings, Steady Improvement

In the time that Oracle has been working to make Java available as an alternative to PL/SQL in the database, it has also made steady, fundamental improvements to the PL/SQL language itself. It has added a great variety of supplied (or built-in) packages that extend the PL/SQL language in numerous ways and directions. It has introduced object-oriented capabilities, implemented a variety of array-like data structures, and in general improved the breadth and depth of the language.

As powerful as SQL is, it simply does not offer the flexibility and power that developers need to create full-blown applications. Oracle's PL/SQL language ensures that we can stay entirely within the operating-system-independent Oracle environment and still write highly efficient applications that meet our users' requirements.

PL/SQL has come a long way from its humble beginnings. With Version 1.0, it was not uncommon for a developer to have to tell his or her manager, "You can't do that with PL/SQL." Today, that statement has moved from fact to excuse. If you are ever confronted with a requirement and find yourself saying, "There's no way to do that," don't repeat it to your manager. Instead, dig deeper into the language, or explore the range of built-in PL/SQL packages offered by Oracle. There is a very good chance that PL/SQL will today allow you to do pretty much whatever you need to do.

In the next section, we take a look at some examples of PL/SQL programs that will familiarize you with the basics of PL/SQL programming.

1.3 So This Is pl/sql

If you are completely new to programming or to working with PL/SQL (or even SQL, for that matter), learning PL/SQL may seem an intimidating prospect. If this is the case, don't fret! We are confident that you will find it easier than you think. There are two reasons for our optimism:

  • Computer languages in general are not that hard to learn, at least compared to a second or third "human language." The reason? It's simply that computers are not particularly smart (they "think"—perform operations—rapidly, but not at all creatively). We must rely on a very rigid syntax in order to tell a computer what we want it to do. So the resulting language is also rigid (no exceptions!) and therefore easier for us to pick up.

  • PL/SQL truly is an easy language as compared to other programming languages. It relies on a highly structured "block" design with different sections, all identified with explicit, self-documenting keywords.

Let's take a look at a few examples that demonstrate some of the key elements of both PL/SQL structure and functionality.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]