Proc Second bomb

Source: Internet
Author: User

First, summary

The following is a brief introduction to Windows proc Configuration development, this time we use the Linux platform to configure the Oracle proc Open
Environment (RedHat Linux 9 + Oracle 92).
Oracle database Development (i). Windows configuration uses proc and Oracle database Development (II). Linux under Configuration using proc "
The purpose of these two articles is only to do some basic introduction, as for the Oracle proc compiler parameters and Linux under the proc Makefile
Related content, will be introduced gradually in subsequent articles.
A word to the disadvantage of the first easy after difficult.

Second, the database environment

Very similar to Windows, first confirm that the components are installed, oracle-application development-
Pro c-c++. After installation, the corresponding executable file is generated in $oracle_home/bin, and the $oracle_home/precomp/demo/proc
Some makefile files and examples are also generated.


Iii. Sample Files

main.pc
---------------------------------------------------------

#include "Sqlca.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void Sql_error (char *msg)
{
printf ("\n%s%s\n", MSG, (char *) SQLCA.SQLERRM.SQLERRMC);
EXEC SQL ROLLBACK RELEASE;
Exit (0);
}

int 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 oracn[30];
EXEC SQL END DECLARE section;

strcpy (Oracn.arr, "system/[email protected]");
Oracn.len = strlen (Oracn.arr);
oracn.arr[oracn.len]= ' + ';

EXEC SQL CONNECT:ORACN;
printf ("\ n [OK connected!]");

return 0;

}

The code is actually the original version of Windows.


Iv. Compile and run

There is no need to modify any parameter files, that is, to create main.pc directly after installation, execute the following command:

$ proc Parse=none iname=main.pc

Pro*c/c++: Release 9.2.0.4.0-production on Thu June 7 14:17:05 2007

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

System default option values taken from:/home/ora/ora9/oracle/precomp/admin/pcscfg.cfg

$ gcc-g-O main main.c-i/home/ora/ora9/oracle/precomp/public-l/home/ora/ora9/oracle/lib-lclntsh

$./main

<ERROR> Ora-12541:tns:no Listener

A successful compile run, you can also use the example in the article "Proc Dynamic SQL Sample (first method)",
Replace//comment all with empty to compile.
Http://blog.csdn.net/liwei_cmg/archive/2006/05/29/759963.aspx
However, there are warning alerts:
/TMP/CCC7E6QE.O (. Text+0xea): In function ' Db_connect ':
/home/ora/develop/src/db.c:385:the ' gets ' function is dangerous and should isn't be used.

This is due to the use of the gets function, see the Man Manual:

BUGS
Never use gets (). Because It is impossible to tell without knowing the
Data in advance how many characters gets () would read, and because
Gets () would continue to store characters past the end of the buffer, it
is extremely dangerous to use. It has been used to break computer
Security. Use Fgets () instead.

It is not a advisable to mix calls to input functions from the stdio
Library with low-level calls to read () for the file descriptor asso-
Ciated with the input stream; The results would be undefined and very
Probably not want.

To solve this problem, you can use the SCANF function to replace the GET, which gets the screen input. such as scanf ("%s", cmd).

Original address: http://blog.chinaunix.net/uid-10376640-id-2960119.html

Proc Second bomb

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.