
Introduction
This chapter introduces you to the Oracle Pro*Ada precompiler. It explains how Pro*Ada helps you to develop applications that manipulate Oracle data. The following topics are included in this chapter:
The Pro*Ada Precompiler
The Pro*Ada precompiler is an application programming tool that allows an Ada program to use embedded SQL language constructs. The precompiler accepts as input a source file that contains both SQL and Ada language constructs. The precompiler then produces an output file that can be compiled normally. The precompiler translates all SQL statements into calls to Oracle runtime library procedures. These procedures perform the Oracle operations requested.
The primary advantage of using a precompiler such as Pro*Ada is that you can develop an application that uses the features of both Ada and SQL. This allows you to develop an application that is more powerful and more flexible than an application based on either of these two languages alone. Ada provides the procedural language framework needed for your application. The embedded SQL statements allow direct access to Oracle. Although precompilation adds a step to the software development process, it greatly reduces the amount of time required to code the application program.
Advantages of Ada
One of the most important reasons to use the Ada language is that it has been designated by the U.S. Government Department of Defense as the standard language that must be used by all embedded system suppliers. Ada was specified by the U.S. Government as a powerful, general-purpose language that encourages consistent software development practices. Some of the characteristics of Ada are:
- Ada is a strongly typed language. The compiler does extensive datatype compatibility checking and range checking to detect usage errors in programs at compile time.
- Ada includes facilities for data structures such as multi- dimensional arrays, records, sets, files, and pointer-based dynamic variables. Ada allows you to define new datatypes that are specific to a particular problem.
- Ada supports real-time and machine-dependent applications at the language level. For example, Ada constructs can be used to accomplish tasking, interrupt handling, and machine code inserts. Ada performs many functions that were previously controlled at the operating system level.
- Ada supports generic software components. A generic software component is not fully-specified code. Rather, it is a template whose parameters can be fully specified when the package is instantiated in a later module. Generic software components support the philosophy of reusable code.
- Ada supports data abstraction. Data abstraction allows programs to employ data representations that are natural to the problem at hand. This eliminates the need to worry about how the computer will represent the data.
- Ada supports information hiding, which allows the designer of a module to define private or implementation-specific objects whose bodies and/or specifications are not visible to the users of that module. Information hiding is enforced through Ada's distinction between specification and body, and through use of the keyword private.
- The Ada language is an ANSI standard. Because of its specification, design, and rigorous standards, Ada is a highly portable language.
The SQL Language
Structured Query Language (SQL) is the standard language for accessing data in an Oracle Server database. Embedded SQL allows your program to perform the following functions:
- CREATE, DROP, and modify database objects dynamically
- manipulate Oracle data using SELECT, INSERT, UPDATE, and DELETE statements
- COMMIT or ROLLBACK a group of statements as a single transaction unit, or logical unit of work, using transaction processing commands
Pro*Ada Features
The Pro*Ada precompiler provides many features that facilitate the Ada software development process. Pro*Ada precompiler features include the following:
- Pro*Ada provides automatic datatype conversion between Oracle and Ada datatypes. However, Pro*Ada does not interfere with type and mode checking by the Ada compiler.
- Pro*Ada follows the ANSI standards for embedding SQL statements in a high-level language.
- Pro*Ada provides full support for dynamic SQL. Dynamic SQL is an advanced programming technique that allows the program to accept or create any valid SQL statement at runtime.
- Pro*Ada allows arrays as host language variables. This allows you to do multiple UPDATEs, INSERTs, or DELETEs, and to receive multiple output data from SELECT and FETCH statements. Array processing can increase the performance of your application considerably, especially in a networked client/server environment.
- Pro*Ada allows Ada to interface directly with SQL*Forms through the SQL*Forms user exit feature.
- By using SQL*Net in combination with the distributed query facility provided by Oracle, Pro*Ada application programs can access data on multiple nodes concurrently.
Special Terms
In the description of the Pro*Ada Precompiler in the following chapters, there are a few special terms that you should know. These terms are best illustrated by considering a SQL query. For example:
SELECT course_name, instructor
INTO :C_NAME, :INST INDICATOR :INST_IV FROM courses
WHERE quarter = 'SPRING' AND dept = :DEPTNO;
This SQL statement contains the following parts:
- two select-list items: COURSE_NAME and INSTRUCTOR
- two host variables, prefixed by colons: C_NAME and INST
- an indicator variable: INST_IV
- a table name in the FROM clause: COURSES
- a constant input value in the WHERE clause: 'SPRING'
- a placeholder for an input variable in the second part of the WHERE clause: :DEPTNO
These terms are defined more precisely
, "An Overview of Embedded SQL."