Linux c 查询Oracle数据库例子


/*
* File: main.c
* Author: oracle
*
* Created on October 11, 2012, 3:14 AM
*/

#include <stdio.h>
#include <stdlib.h>
#include "sqlora.h"
/*
*
*/
int main(int argc, char** argv) {

sqlo_db_handle_t dbh;
int sd;
int sth;

const char *cstr = "xia/pass123@DBInstance";
const char **v;


if (SQLO_SUCCESS != sqlo_init(SQLO_OFF,1,100))

{
printf ("sql_init failed. Exiting\n");
exit(1);
}


if (SQLO_SUCCESS != sqlo_connect(&dbh, cstr)){
printf ("connect failed. Exiting\n");
exit(1);
}else
{
printf ("connect successfully. Exiting\n");
}


char *select_stmt="SELECT * FROM status";

if (0>(sd=sqlo_open(dbh, select_stmt, 0, NULL)))
{

printf("open table failed: %s\n", sqlo_geterror(dbh));
return 0;

}
else
{
printf("open table");
}
printf("\n");
while(0==sqlo_fetch(sd,1)){

v=sqlo_values(sd,NULL,1);
printf("Result is : %s %s %s %s %s %s\n",v[0],v[1],v[2],v[3],v[4],v[5]);
}
sqlo_finish(dbh);
return (EXIT_SUCCESS);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值