Oracle Pro*c Learning Notes

Source: Internet
Author: User
Tags error code execution include variables sql error sql error code
oracle| notes
At present, it is necessary to use Oracle's pro*c in rebuilding a service program under Linux. The following is a transcript of the study:

Introduction of Pro*c

In addition to providing database access to database access tools such as SQL * Plus,sql * forms, Oracle can access Oracle databases in the form of SQL statements or Oracle functions embedded in the third generation of high-level languages. At present Oracle support language has c,fortran,pascal, and so on, the part that uses C is called Pro*c. The embedded SQL statement includes the DML,DDL statement, can be implemented dynamically, modify, delete the table in the database, you can query, insert, delete tables in the table of rows, implementation of database operations and rollback. The benefits of using the embedded SQL statements in the third generation high-level language are as follows: three.

1, the combination of procedural language and non-procedural language can meet a variety of complex requirements of the application, but also can refer to Windows and mouse technology.

2, can make the development of the application with management resources, SQL statement execution and indicators and other capabilities

3, improve the execution speed of the application.

All PRO*C programs are compiled by Oracle precompiled system before compiling, the precompiled system allows the use of dynamic SQL technology, can realize internal and external data type conversion, can embed Pl/sql block, By using data type equivalence to control Oracle interpretation input data and formatted output data, you can examine the syntax and semantics of Embedded SQL statements, and you can use array SQL variables to make error diagnosis using SQLCA and Oraca.

Second, the PRO*C program structure

The general Pro*c mainly consists of two parts, the external Description section and the program main body.

External description Segment: The main description of the program to be referred to the external variables and functions, including the Description section, the communication area description and C language related statements.

Program body: With the General C program's main part, you can use more than one function or only main function. The function can include local description section, local communication area declaration and C local variable declaration.

The description section syntax is as follows:

EXEC SQL BEGIN DECLARE section;

(SQL variable Declaration)

EXEC SQL end DECLARE section;

The communication Area Description statement is: EXEC SQL INCLUDE SQLCA;

Where SQLCA is the structure, the content can view the Oracle precompiled System header file Sqlca.h (the path under Windows is: $orahome \precomp\public\)

struct sqlca{char sqlcaid[8];    int sqlabc;    int sqlcode;         /* Equivalent to SQLCODE indicates that the SQL error code struct {/* struct body is equivalent to SQLERRM user storing SQL error messages.         unsigned short sqlerrml;     Char sqlerrmc[70];    } SQLERRM;    Char Sqlerrp[8];    int sqlerrd[6];    Char Sqlwarn[8]; Char Sqlext[8];


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.