C language development process, need to operate on the database, using Oracle database generally will use the Oracle proc/C ++ precompiler. This article, from the official Oracle documentation, provides a detailed introduction to the Oracle Proc/C ++ precompiler, its role in developing applications that manipulate Oracle data, and what it enables your applications to do.
Introduction to Oracle precompiler
The Oracle precompiler is a programming tool that enables users to embed SQL statements in high-level source programs. As the figure shows, the precompiler takes the source program as input, converts the embedded SQL statement into a standard Oracle runtime library call, and produces a modified source program that can be compiled, linked, and executed in the usual way.
Use Oracle Pro*C/C++ precompiler
The Oracle Pro*C/C++ precompiler enables you to use the power and flexibility of SQL in your applications. A convenient, easy-to-use interface gives your applications direct access to Oracle.
Unlike many application development tools, Pro*C/C++ allows you to create highly customized applications. For example, you can create a user interface that includes the latest Windows and mouse technology. You can also create applications that run in the background without user interaction.
In addition, Pro*C/C++ helps you fine-tune your application. It allows for close monitoring of resource usage, SQL statement execution, and various runtime metrics. Using this information, you can change program parameters for best performance.
Although precompilation adds a step to the application development process, it saves time. A precompiler that converts each embedded SQL statement into a call to the Oracle Runtime library (SQLLIB). The Pro*C/C++ precompiler also analyzes host variables, defines structure-to-column mappings, and performs semantic analysis of embedded SQL statements with SQLCHECK=FULL.
3. Use SQL statements
SQL statements are required to access and manipulate Oracle data. Whether you use SQL through SQL*Plus interaction or embed it in your application depends on the job at hand. Use embedded SQL if the job requires C or C++ procedural capability or must be completed regularly.
SQL has become the preferred database language because it is flexible, powerful, and easy to learn. Because it is non-procedural, it lets you specify what you want done without specifying how to do it. Some English-like statements make it easy to manipulate one or more Oracle rows at a time.
You can execute any SQL (not SQL*Plus) statement from the application. For example, you can
Create, change, and drop database tables dynamically
SELECT, INSERT, UPDATE, and DELETE data rows
COMMIT or ROLLBACK transactions
You can use SQL*Plus to test SQL statements interactively before embedding them in your application. Typically, switching from interactive SQL to embedded SQL requires only minor changes.
Pro*C/C++ precompiler benefits
As the figure shows, Pro*C/C++ offers many features and benefits that you can help to develop effective, reliable applications.
Pro * C/C + + support:
- Write applications in C or C++.
- Follow ANSI/ISO standards to embed SQL statements in high-level languages.
- Leverage dynamic SQL, an advanced programming technique that allows your program to accept or build any valid SQL statement at run time.
- Design and develop highly customized applications.
- Write shared server process applications.
- Automatic conversion between Oracle internal data types and high-level language data types.
- Improve performance by embedding PL/SQL transaction processing blocks in your application.
- Inline and specify useful precompiler options on the command line and change their values during precompilation.
- Use data type equivalence to control how Oracle interprets input data and formats output data.
- Precompile multiple program modules separately and then link them into an executable program.
- A complete review of the syntax and semantics of embedded SQL data manipulation statements and PL/SQL blocks.
- Use Oracle Net to access Oracle databases concurrently on multiple nodes.
- Use arrays as input and output program variables.
- A snippet of code in a host program is precompiled conditionally so that it can run in different environments.
- Interface directly with SQL*Forms by using user exits written in high-level languages.
- Use SQL Communications Area (SQLCA) and the WHENEVER or DO statement to handle errors and warnings.
- Use a set of enhanced diagnostics provided by the Oracle Communications Area (ORACA).
- Use user-defined object types in the database.
- Use collections (variables and nested tables) in a database.
- Use LOBs (large objects) in the database.
- Data is stored in a database using the national character set.
- Use OCI (Oracle Calling Interface) functions in your program.
- Use multithreaded applications.
- Microsoft Visual Studio.net 2002/2003 Support
- Pro*C/C++ is a full-featured tool that supports a professional approach to embedded SQL programming.