SQL*Plus was not designed to be a tool used for writing complex scripts. Its capabilities can't compare to those of your typical Unix shell, such as the Korn shell or the Bourne shell. Nor does it have anywhere near the capabilities of an advanced scripting tool such as Perl. Most noticeably, SQL*Plus suffers from the following limitations:
Because of these limitations, SQL*Plus is best suited to executing top-down scripts that don't require any branching, looping, or error handling. Most of the scripts you have seen so far in this book fall into this category. Many are reports that set up some column and page formatting and then execute a query. If something goes wrong, you may not see any data in the report, or you may see some SQL or SQL*Plus error messages.
This limited scripting support is fine when it comes to producing a report. After all, if a report fails, you can fix the problem and rerun the report. But what if you are performing a more complex and critical task? What if you are summarizing some data, posting the summary results to a summary table, and then deleting the underlying detail? In that case, you certainly don't want to delete the data if the summarization failed. You need some kind of error-handling mechanism.
This chapter describes some specific ways to work around these limitations of SQL*Plus. Believe it or not, it is possible, using only SQL*Plus, to implement branching and to validate user input. There are even ways to deal with repetitive tasks without resorting to a loop. You will learn about bind variables and see how they better enable you to mix PL/SQL code into your SQL*Plus scripts. You will see how bind variables can make the job of developing queries for application programs easier.
Introduction to SQL*Plus
A Lightning SQL Tutorial
Generating Reports with SQL*Plus
Creating HTML Reports
Writing SQL*Plus Scripts
Extracting and Loading Data
Exploring Your Database
Tuning and Timing
The Product User Profile
Customizing Your SQL*Plus Environment
Appendix A. SQL*Plus Command Reference
Appendix B. SQL*Plus Format Elements
Oracle SQL*Plus: The Definitive Guide (Definitive Guides)
Authors: Jonathan Gennick