What is pro * C/C ++?

Source: Internet
Author: User

Oracle supports embedding SQL statements in several advanced languages or calling Oracle database functions to access the database. They are C, COBOL, Ada, Pascal, PL/I, etc. These languages are called host languages, and the programs they develop are called Pro * programs, such as Pro * C, pro * Cobol.
Proc is available in Oracle client software and can be selected when oracle is installed.

1. What is pro * C/C ++?
An application developed by embedding SQL statements in the procedural programming language C/C ++.
2. Brief description:
The SQL used in general programming languages is called embedded SQL. The objective is that pro * C/C ++ will make C/C ++ a tool for accessing databases.

There are three methods to access the database in the Oracle database management and system;

(1) use SQL * Plus, which has SQL commands to access the database through interactive applications;

(2) applications developed by application development tools in the fourth generation language access the database. These tools include SQL * froms, Ql * reportwriter, and SQL * menu;

(3) access using SQL language or Oracle database function calls embedded in the third generation language.

Pro * C is one of the third development tools. It perfectly integrates Procedural Language C with non-procedural language SQL, and has complete process processing capabilities, it can also complete the processing tasks of any database, allowing users to program various types of reports.

The SQL language can be embedded in the Pro * C program. These SQL languages can be used to dynamically create, modify, and delete tables in the database, you can also query, insert, modify, and delete rows in a database table, and commit and roll back transactions.

PL/SQL blocks can be embedded in Pro * C programs to improve application performance, especially in network environments, which can reduce the total overhead of network transmission and processing.

2. For the program structure of Pro * C, the Pro * C program is actually a C program embedded with SQL statements or PL/SQL blocks, so its composition is similar to the C program.

Oracle 8.16 for rhlinux6.2 Pro * C Environment

1. Pro * C:

 

Oracle Database is one of the best database products and is widely used. With its in-depth application, it has become a choice for many systems to use Oracle and C to compile application systems, the knowledge of Oracle and C language interfaces should be mastered and very useful.

Pro * C is an Oracle pre-compiler which is a programming tool that embeds SQL statements into C language programs.

The pre-compiler uses the source program as the input, then translates the SQL statements embedded in the program, converts them into calls to the standard Oracle Runtime Library, and finally generates a modified source program. Compile and link the modified source program to form an executable file.

2. Environment Configuration:

 

A. Description:

The Oracle pre-compiler is installed by default or by default during Oracle 8i installation. If Pro * C is installed, the executable program proc is available in the $ ORACLE_HOME/bin path, and the corresponding pre-compiled environment without configuration. To enable the Pro * C pre-compiler to work, we must also configure the environment.

Oracle's Pro * C configures the environment by changing the option value of the pre-compiler. The basic format of precompiled commands is as follows:

Proc option name = option value source file

 

You can also change the option value to the file specified by config.

Proc options

Auto_connect

Allow automatic connection to the ops $ account

Char_map

Ing character array and string

Close_on_commit

Close all commit cursors

Codekr_c

Code type to be generated

Comp_charset

Character Set types supported by C Compiler

Config

Overwrite the system configuration file with another configuration file

Cpp_suffix

Overwrite the default C ++ file name suffix

Dbmsnative

Compatibility mode

Def_sqlcode

Generate '# define sqlcode sqlca. sqlcode' macro

Define

Define Preprocessor symbols

Durationtransaction

Set the pin duration of objects in the cache.

Dynamic

Specify oracle or ANSI dynamic SQL Semantics

Errors

Whether to send the error message to the terminal

Errtype

The name of the input file list is incorrect.

FIPS

The FIPS flag of ANSI is invalid.

Header

Specify the file extension for the precompiled title

Hold_cursor

Control cursor retention in the cursor Cache

INAME

Input File Name

Include

Including the directory path of the file

Intype

Input File Name For type information

Lines

Add the # Line command to the generated code

Lname

Overwrite the default list file name

Ltype

Data volume generated in the list file

Maxliteral

Maximum length of the generated text string

Maxopencursors

Maximum number of open cursors in the cache

Mode

The Code complies with Oracle or ANSI rules

Nls_char

Country language character variable

Nls_local

How to Control NLS character Semantics

Objects

Supported Object Types

Oname

Output file name

Region

Control the use of objective

Pagelen

Page length of List Files

Parse

Control Non-SQL code for syntax analysis

Prefetch

Number of pre-read rows during cursor open

Release_cursor

Controls the release of a cursor from the cache

Select_error

Incorrect Control Selection flag

Sqlcheck

Total amount of SQL verification during compilation time

Sys_include

Directory of the system title File

Threads

Multi-threaded applications

Type_code

Use oracle or ANSI code for dynamic SQL

Unsafe_null

Allow> null reading without variable indication

Userid

Username/password [@ dbname] connection string

Varchar

Implicit varchar structure is allowed

Version

Version of the object to be returned

 

We can use the default values for most options, but several of them need to be configured.

L config: Specify the config file of Proc. The default proc configuration file is $ ORACLE_HOME/precomp/admin/pcscfg. cfg. We can edit the config file we want to use.

L include: includes the directory path of the file, which is generally configured in the config file, which is defined by default in pcscfg. cfg.

L sys_include: directory of the system header file, which is generally configured in the config file. The default definition is in pcscfg. cfg. Note that the path of the default system header file is incorrect. For example
Sys_include = ($ ORACLE_HOME/precomp/public,/usr/include,/usr/lib/GCC-lib/i386-redhat-linux/egcs-2.91.66/include)

Luserid: User Name/password [@ dbname] connection string

B. Configuration:

The configuration is relatively simple. You only need to copy the default> config file to the path where the source program is located and modify the userid.

Use the following command to pre-compile the proc source file and output the corresponding C source program.

Proc Config = myconfg. cfg INAME = myprog. PC oname = myprog. c

Pro * C will pre-compile the proc source file specified by INAME and output the file specified by oname.

3. Editing environment:

Pre-compilation only translates the proc source file into the C source file. To compile the target file generated by compilation of different source files, you must specify the library and Oracle Interface Program (Proc program) required for the compilation) the required client shared library is distributed in many paths. For the convenience of association, Oracle provides the $ ORACLE_HOME/precomp/demo/proc/demo_proc.mk file.

Run the following command:

 

Make-F demo_proc.mk objs = "myporg. O mydb. O" EXE = myprog. e build

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.