博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

通过文件操作Oracle数据库

Posted on 2011-08-23 14:41  bug yang  阅读(166)  评论(0编辑  收藏  举报
#include<string>
#include
<stdlib.h>
#include
<string.h>
#include
<unistd.h>
#include
<fcntl.h>
#include
<errno.h>
#include
<time.h>

int main()
{
FILE
*fs=fopen("/root/uvsync/test.sql","w+");
if(fs)
{
fputs(
"insert into test (id,name) values('2','hello world2');",fs);
printf(
"ok");
}
else
{
printf(
"error");
}
fclose(fs);
char cmd_sql[100];
sprintf(cmd_sql,
"sqlplus 用户名/密码 @%s","test.sql");
system(cmd_sql);
}