Configuring Oracle's PRO*C Environment

Source: Internet
Author: User

1. How to access the database
In Oracle database management and system, there are three ways to access the database;
⑴. With Sql*plus, it has SQL commands to access the database with an interactive application;
⑵. Applications developed using the fourth-generation language application development tools to access the database, these tools are sql*froms,ql*reportwriter,sql*menu, etc.
⑶. Access is accessed using SQL language or Oracle library functions embedded in a third-generation language.

Pro*c is one of the third development tools, it combines process-based language C with non-process language SQL, with complete process capability and can complete any data.
The substandard goods task of the library enables users to programmatically complete various types of reports. The SQL language can be embedded in the PRO*C program, and these SQL languages can be used to dynamically build, modify, and
Deleting a table from a database can also query, insert, modify, and delete rows in a database table, as well as commit and rollback transactions. You can also embed PL/SQL blocks in the PRO*C program to
Improve the performance of your application, especially in a networked environment, to reduce the total cost of network transmission and processing.

2. Compilation Process
Pro*c is a pre-compiler for Oracle, a programming tool that embeds SQL statements into a C language program and compiles as follows:
pro*c source file (*.pc)-C source file (*.C)-target file (*.O)-executable file。
    
The precompiled compiler takes the source program as input, then translates the SQL statements embedded in the program into calls to the standard Oracle runtime and finally generates a modified source program.
The executable file is formed by compiling and linking the modified source program.

3. pro*c header files and library files

    

4. Oracle Precompiled Option Profile
By default, the $oracle_home/bin path has the executable program proc and the corresponding non-configured precompiled environment. Pro*c a lot of options when precompiling, you can put it in a file
If you do not specify a configuration file at precompilation, the default profile is $ORACLE _home/precomp/admin/pcscfg.cfg
Edit Pcscfg.cfg File:
Sys_include= (/opt/oracle/precomp/public,/usr/lib/gcc/i386-redhat-linux/4.1.1/include,/usr/lib/ i386-redhat-linux4e/include/
Bits,/home/uriel/git-2.0.3/compat/vcbuild/include,/usr/lib/i386-redhat-linux4e/include)
Ltype=short

The sys_include of this file should contain the path where Sqlca.h and Sqlda.h are located (otherwise compile times: ' Sqlca ' is not declared), I am here for/opt/precomp/public. Also need to include
The path where stddef.h is located, I am here for/usr/lib/gcc/i386-redhat-linux/4.1.1/include. If these two files you do not know in what position, can pass
#find/-name "Sqlca.h"
#find/-name "Stddef.h"
To find. In addition, the common header file path can be added, such as/usr/include.

5. Oracle precompilation Options

    

    

    

    
6. Example of compiling process (Specific implementation can refer to makefile blog)
First, the C code program with Embedded SQL (usually the program ends with a. PC, or PC code) uses proc to do a pre-compilation, translating the embedded SQL inside into the C code that represents the database function call.
The second step is to use the C compiler to compile the C-code connection (which contains the library libclntsh.so in the database) into an executable file.
. PC->.C: $proc iname=sample1.pc oname=sample1.c
. C->.O $CC –c sample1.c
.o-> executable file $cc –l$oracle_home/lib –lclntsh –o sample1 sample1.o

Embedded C compile time also need to link-lclntsh Library (library libclntsh.so in database)

Configuring Oracle's PRO*C Environment

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.