Database proc Programming One

Source: Internet
Author: User

 proc Programming Embedded Sql:sql writing to a C language Program proc programming header file path app\xxx\product\11.2.0\dbhome_1\precomp\ Publicproc Programming Note that the proc compiler will also use the header file in the GCC compiler, so you need to configure it in the proc compiler, plus the system header file path profile path is: app\xxx\product\11.2.0\dbhome_1\precomp\admin\pcscfg.cfgproc Development Process1. Proc Tool Precompiled *.pc==>. Cproc compilation options: Parse=full|none (defaultFull forC,others forC + +) code=ansi_c| CPP (defaultAnsi_c) C language compilation: proc source file generation file C+ + Compile: Proc source file generation file Parse=none code=CPP2. Linux under Compile Gcc-o dm01_hello dm01_hello.c-i/home/oracle_11/app/oracle/product/11.2.0/db_1/precomp/ Public     -l/home/oracle_11/app/oracle/product/11.2.0/db_1/lib-Lclntsh--Linux View Oracle error code: Oerr ora error code3. Execute application proc Program structure include header file (c/c++ and Pro*c/c++define a variable definition function main connection database: Connect SQL ACTION statement: EXEC SQL ... Handling exception: Exception handler disconnect: EXEC SQL COMMIT. ROLLBACK Work Release
#include <stdio.h>#include<stdlib.h>#include<string.h>#include"sqlca.h"//Define the host variable (SQL variable) firstEXEC SQL BEGIN DECLARE section; Char* serverid="scott/123456"; EXEC SQL END DECLARE section;voidMain () {intret=0; //using host variables in the C languageprintf"serverid=%s\r\n", ServerID); //connecting to a databaseEXEC SQL Connect:serverid; if(sqlca.sqlcode!=0) {ret=Sqlca.sqlcode; printf ("Connect err:%d", ret); System ("Pause"); } printf ("Connect ok!\r\n"); //COMMIT Transaction DisconnectEXEC SQL commit release; printf ("Oracle closed!\r\n"); System ("Pause");}

Database proc Programming One

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.