关于Proc的使用方法总结

Oracle文档链接如下:http://docs.oracle.com/cd/E11882_01/appdev.112/e10825/pc_agsmp.htm

其中值得注意的有:

1. 使用exec sql include包含文件的使用。搜素顺序如下附录1。

2. parse对预编译产生的影响。

INCLUDE

Purpose

Specifies a directory path for files included using the #include or EXEC SQL INCLUDE directives.

Syntax

INCLUDE=pathname or INCLUDE=(path_1,path_2,...,path_n)

Default

Current directory and paths built into Pro*C/C++.

Usage Notes

Can be entered inline or on the command line.

You use INCLUDE to specify a directory path for included files. The precompiler searches directories in the following order:

  1. the current directory

  2. the system directory specified in a SYS_INCLUDE precompiler option

  3. the directories specified by the INCLUDE option, in the order they are entered

  4. the built-in directories for standard header files

You normally do not need to specify a directory path for Oracle-specific header files such as sqlca.h and sqlda.h.

Note:

If you specify an Oracle-specific filename without an extension for inclusion, Pro*C/C++ assumes an extension of  .h. So, included files should have an extension, even if it is not  .h.

For all other header files, the precompiler does not assume a .h extension.

You must still use INCLUDE to specify directory paths for non-standard files, unless they are stored in the current directory. You can specify more than one path on the command line, as follows:

... INCLUDE=path_1 INCLUDE=path_2 ...

Note:

If the file you want to include resides in another directory, make sure that there is no file with the same name in the current directory.

The syntax for specifying a directory path using the INCLUDE option is system specific. Follow the conventions used for your operating system

Note:

For the INCLUDE option, the precedence of option values gets reversed. Unlike other options in which the values get overwritten, INCLUDE appends all the directory files that are mentioned in:
  • Precompiler

  • Pro*C/C++ system configuration file

  • Pro*C/C++ user configuration file

  • Command line

  • Inline

However, there is a difference between passing values within or without brackets. If you pass a single value or directory list within brackets, then the existing value of INCLUDE is overwritten. If you pass the list as a simple value without brackets, it will supplement any existing value.

--------------------------------

Parsing Code

You must be able to control the effect of the Pro*C/C++ C parser on your code. You do this by using the PARSE precompiler option, which controls how the precompiler's C parser treats your code.

The values and effects of the PARSE option are:

Table 12-1 Values and Effects of the PARSE Option

ValuesEffects

PARSE=NONE

The value NONE has the following effects:

  • C preprocessor directives are understood only inside a declare section.

  • You must declare all host variables inside a Declare Section.

  • Precompiler release 1.x behavior

PARSE=PARTIAL

The value PARTIAL has the following effects:

  • All preprocessor directives are understood

  • You must declare all host variables inside a Declare Section

This option value is the default if CODE=CPP

PARSE=FULL

The value FULL has the following effects:

  • The precompiler C parser runs on your code.

  • All Preprocessor directives are understood.

  • You can declare host variables at any place that they can be declared legally in C.


This option value is the default if the value of the CODE option is anything other than CPP. It is an error to specify PARSE=FULL when CODE=CPP.

To generate C++ compatible code, the PARSE option must be either NONE or PARTIAL. If PARSE=FULL, the C parser runs, and it does not understand C++ constructs in your code, such as classes.

Output Filename Extension

Most C compilers expect a default extension of ".c" for their input files. Different C++ compilers, however, can expect different filename extensions. The CPP_SUFFIX option provides the ability to specify the filename extension that the precompiler generates. The value of this option is a string, without the quotes or the period. For example, CPP_SUFFIX=cc, or CPP_SUFFIX=C.

System Header Files

Pro*C/C++ searches for standard system header files, such as stdio.h, in standard locations that are platform specific. Pro*C/C++ does not search for header files with extensions such as hpp or h++. For example, on almost all UNIX systems, the file stdio.h has the full path name /usr/include/stdio.h.

But a C++ compiler has its own version of stdio.h that is not in the standard system location. When you are precompiling for C++, you must use the SYS_INCLUDE precompiler option to specify the directory paths that Pro*C/C++ searches to look for system header files. For example:

SYS_INCLUDE=(/usr/lang/SC2.0.1/include,/usr/lang/SC2.1.1/include)

Use the INCLUDE precompiler option to specify the location of non-system header files. The directories specified by the SYS_INCLUDE option are searched before directories specified by the INCLUDE option. See also: "INCLUDE".

If PARSE=NONE, the values specified in SYS_INCLUDE and INCLUDE for system files are not relevant, since there is no need for Pro*C/C++ to include system header files. (You can, of course, still include Pro*C/C++-specific headers, such sqlca.h, using the EXEC SQL INCLUDE statement.)

Example Programs


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值