EXEC SQL SELECT sysdate INTO :nowtime FROM dual; printf("Now is %s !\n", nowtime.arr); EXEC SQL COMMIT RELEASE; }上面的东西保存为 a.pc 使用proc预编译,windows下面有GUI界面。 可以得到a.c使用操作系统c语言编译器,例如AIX的cc、linux的gcc、windows的cl(vc的命令行编译器)或者使用vc的ide都可以很方便的编译得到可执行代码。 打印出当前日期时间。
按couchman(couchman) 说的那样子,会出这样的错误:请问couchman(couchman) 是什么原因? [oracle@linux oracle]$ gcc a.c /tmp/ccI9XUfa.o: In function `main': /tmp/ccI9XUfa.o(.text+0x1d7): undefined reference to `sqlcxt' /tmp/ccI9XUfa.o(.text+0x34f): undefined reference to `sqlcxt' /tmp/ccI9XUfa.o(.text+0x3df): undefined reference to `sqlcxt' collect2: ld returned 1 exit status
pro*c源码->c源码->可执行文件
你这样写,我还是不太明白,
“源码->pro*c编译器->c编译器”是源码经pro*c编译器编译然后在用
C编译器就成了可执行文件了吗?“pro*c源码->c源码->可执行文件”还是pro*c源码经pro*c编译器编译
成c源码再由c编译器编译成可执行文件?
#include <stdio.h>
#include <string.h>
#include <sqlca.h>
#define UNAME_LEN 20
#define PWD_LEN 40
VARCHAR username[UNAME_LEN];
varchar password[PWD_LEN];
varchar nowtime[100];
main()
{
strncpy((char *) username.arr, "SCOTT", UNAME_LEN);
username.len = strlen((char *) username.arr);
strncpy((char *) password.arr, "TIGER", PWD_LEN);
password.len = strlen((char *) password.arr);
EXEC SQL CONNECT :username IDENTIFIED BY :password;
EXEC SQL SELECT sysdate INTO :nowtime FROM dual;
printf("Now is %s !\n", nowtime.arr);
EXEC SQL COMMIT RELEASE;
}上面的东西保存为 a.pc
使用proc预编译,windows下面有GUI界面。
可以得到a.c使用操作系统c语言编译器,例如AIX的cc、linux的gcc、windows的cl(vc的命令行编译器)或者使用vc的ide都可以很方便的编译得到可执行代码。
打印出当前日期时间。
[oracle@linux oracle]$ gcc a.c
/tmp/ccI9XUfa.o: In function `main':
/tmp/ccI9XUfa.o(.text+0x1d7): undefined reference to `sqlcxt'
/tmp/ccI9XUfa.o(.text+0x34f): undefined reference to `sqlcxt'
/tmp/ccI9XUfa.o(.text+0x3df): undefined reference to `sqlcxt'
collect2: ld returned 1 exit status
但是看上去是无法解析对‘sqlcxt’的引用,
怀疑是不是一些必须的库和头文件没有包含在编译时的路径中