Oracle Proc*c初步学习总结
2012-02-10 18:37
295 查看
有了oracle环境后,开始在Linux下编写proc*c 初始例子一般都是一个连接到数据库的程序:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sqlca.h"
EXEC SQL BEGIN DECLARE SECTION;
char *uid = "scott/tiger@CENTOS";
EXEC SQL END DECLARE SECTION;
int main()
{
EXEC SQL CONNECT :uid;
printf("%s",sqlca.sqlerrm.sqlerrmc);
if(sqlca.sqlcode == 0)
printf("Success!!!\n");
else
printf("Fail!!!\n");
}
将其保存为.pc的源程序文件。
流程为 (.pc源文件——>使用proc预编译为.c文件——>使用gcc编译连接——>生成可执行文件)。
使用proc预编译的时候需要注意以下几点 :
1、要正确的配置/u01/app/oracle/product/10.2.0/db_1/precomp/admin/pcscfg.cfg这个文件中的sys_include=(/u01/app/oracle/product/10.2.0/db_1/precomp/public,/usr/include,/usr/lib/gcc/i386-redhat-linux/4.1.1/include,/usr/lib/gcc/i386-redhat-linux/3.4.6/include)。查看本机的所拥有的库文件:find /usr/lib -name "stddef.h" -print.修改相应的配置。
若没有配置正确会产生一个错误信息:PCC-S-02015, unable to open include file
下面是比较全面的解析(E文的)
Cause: The precompiler could not open the listing file. This message can result from many causes. For example:
A pathname for a specified listing file contains a non-existent directory.
An operating-system error occurred because the file system or disk is full.
Write permission on the specified directory has not been granted.
Action: Track down the cause of the error, as suggested above, and correct it.
2、如果配置好后出现这个错误:PCC-F-02081, CMD-LINE: Unterminated option value list or value list was truncat ed.
Cause: An option that takes a list of values was entered. The value list did not have a closing parenthesis. This error may also occur if the list of values entered on a single line was too long and Pro*C truncated it.
Action: Ensure that all value lists are terminated with a closing parenthesis. Split long value lists into individual entries.
不要在一个include中写入太长的内容,太多的话Pro*C会把它截断的。可以分开写或者确认其长度在适当的值内 。
最后使用gcc命令将其生成 gcc -o example example.c -I /u01/app/oracle/product/10.2.0/db_1/precomp/public/ -L /u01/app/oracle/product/10.2.0/db_1/lib/ -l clntsh
当然可以将该命令写入一个文件中执行。
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "sqlca.h"
EXEC SQL BEGIN DECLARE SECTION;
char *uid = "scott/tiger@CENTOS";
EXEC SQL END DECLARE SECTION;
int main()
{
EXEC SQL CONNECT :uid;
printf("%s",sqlca.sqlerrm.sqlerrmc);
if(sqlca.sqlcode == 0)
printf("Success!!!\n");
else
printf("Fail!!!\n");
}
将其保存为.pc的源程序文件。
流程为 (.pc源文件——>使用proc预编译为.c文件——>使用gcc编译连接——>生成可执行文件)。
使用proc预编译的时候需要注意以下几点 :
1、要正确的配置/u01/app/oracle/product/10.2.0/db_1/precomp/admin/pcscfg.cfg这个文件中的sys_include=(/u01/app/oracle/product/10.2.0/db_1/precomp/public,/usr/include,/usr/lib/gcc/i386-redhat-linux/4.1.1/include,/usr/lib/gcc/i386-redhat-linux/3.4.6/include)。查看本机的所拥有的库文件:find /usr/lib -name "stddef.h" -print.修改相应的配置。
若没有配置正确会产生一个错误信息:PCC-S-02015, unable to open include file
下面是比较全面的解析(E文的)
Cause: The precompiler could not open the listing file. This message can result from many causes. For example:
A pathname for a specified listing file contains a non-existent directory.
An operating-system error occurred because the file system or disk is full.
Write permission on the specified directory has not been granted.
Action: Track down the cause of the error, as suggested above, and correct it.
2、如果配置好后出现这个错误:PCC-F-02081, CMD-LINE: Unterminated option value list or value list was truncat ed.
Cause: An option that takes a list of values was entered. The value list did not have a closing parenthesis. This error may also occur if the list of values entered on a single line was too long and Pro*C truncated it.
Action: Ensure that all value lists are terminated with a closing parenthesis. Split long value lists into individual entries.
不要在一个include中写入太长的内容,太多的话Pro*C会把它截断的。可以分开写或者确认其长度在适当的值内 。
最后使用gcc命令将其生成 gcc -o example example.c -I /u01/app/oracle/product/10.2.0/db_1/precomp/public/ -L /u01/app/oracle/product/10.2.0/db_1/lib/ -l clntsh
当然可以将该命令写入一个文件中执行。
相关文章推荐
- oracle学习的初步总结以及date 类型的运用
- oracle学习总结(二)
- 初步学习多线程的总结
- 机器学习笔记之监督学习与无监督学习的一些初步总结
- Oracle权限学习总结
- HDFS初步学习的总结
- oracle学习总结一(基础)
- 【学习总结】Oracle数据的基本用法
- oracle简单学习总结(三)——函数
- Redis初步学习总结
- Oracle学习总结(二)——数据库基础
- Oracle学习总结(三)——SQL基础
- oracle学习总结2
- oracle学习总结(一)
- oracle学习总结(一)
- Android加固与脱壳学习之加固初步总结(1)
- oracle学习总结-------数据库的约束
- oracle学习总结三(创建脚本)
- 学习总结 初步了解HTML课程
- 学习Oracle一个星期以来的总结