Oracle Database development (1). Configure proc in Windows

Source: Internet
Author: User

Oracle Database development (1). Configure proc in Windows

20070606

Papayas

I. Summary

Proc is a development interface provided by Oracle database and supports multiple languages. Although proc debugging and maintenance are inconvenient,
However, the structured and clear embedded SQL has become a common method for controlling database access in C/C ++.
This article first introduces how to use visual c ++ 6.0 and Visual C ++. Net to configure proc
Development environment.

Ii. database environment

Confirm that the components are installed, Oracle-Application Development-Pro C-C ++. Sometimes in Oracle
The installed component is displayed in the built-in component tool, but there are no corresponding components in the File menu and folder. The solution is to reinstall the tool.

Iii. Use the example File

Sqlmain. C (the extension does not matter)
----------------------------------------------

# Include "sqlca. H"
# Include <stdio. h>
# Include <string. h>
# Include <stdlib. h>

// Display unexpected errors
Void SQL _error (char * MSG)
{
Printf ("/n % S % s/n", MSG, (char *) sqlca. sqlerrm. sqlerrmc );
Exec SQL rollback release;
Exit (0 );
}

Void main (){

Exec SQL include sqlca;
Exec Oracle option (release_cursor = yes );
Exec SQL whenever sqlerror do SQL _error ("<error> ");

Exec SQL begin declare section;
Varchar limit N [30];
Exec SQL end declare section;

Strcpy (Limit N. Arr, "system/sys @ unixdb ");
Limit N. Len = strlen (Limit N. Arr );
Limit N. Arr [limit N. Len] = '/0 ';

Exec SQL CONNECT: Limit N;
Printf ("/n [OK connected!] ");

}

Use pro C-C ++ compiled into C language files, after success will prompt green "√ ":

Source. C (the file is long and is not listed here)

Iii. Visual C ++ 6.0

1. New Project-> Win32 console application creates an empty console project.

2. Add the compiled source. c file

3. In tools> Options> directories, add the lib directory and include directory of Proc.

The local directory is as follows:

Library files

E:/Oracle/ora92/precomp/lib

Include files

E:/Oracle/ora92/precomp/Public

4. Add
The linked file orasql9.lib of Proc is automatically updated in project options.

5. Compile and run

Enter the wrong password:
<Error> ORA-01017: invalid username/password; logon denied
Connection success prompt:
[OK connected!]

Iv. Visual C ++. net

1. Create a project> visual c ++> Win32> console to create an empty console project.

2. Add the compiled source. c file

3. Add the lib directory and include directory of Proc to the tool-> options-> Project-> VC ++ directory.

The local directory is as follows:

Library files

E:/Oracle/ora92/precomp/lib

Header file

E:/Oracle/ora92/precomp/Public

4. Select project-> properties-> Configuration properties-> blockchain node-> input-> Add additional dependencies
Link file orasql9.lib of Proc


5. Compile and run

Enter the wrong password:
<Error> ORA-01017: invalid username/password; logon denied
Connection success prompt:
[OK connected!]


V. Summary

This article only uses a simple example of database connection. For examples of practical reference, see:
Proc dynamic SQL example (method 1, 2, 3)
Http://blog.csdn.net/liwei_cmg/archive/2006/05/29/759963.aspx

In addition, many tutorials in this area can be searched online. In E:/Oracle/ora92/precomp/demo/proc
There are also many specific instances, which are worth your reference. The following describes how to configure and use proc in Unix/Linux environments.

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.