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);
} 相关推荐
Android开发CXY 2020-11-11
lpkwxl 2020-06-17
RealJianyuan 2020-06-14
pbyanglove 2020-06-09
徐建岗网络管理 2020-06-09
fengjing81 2020-06-06
lynjay 2020-06-02
wujingsheng0 2020-05-16
吴小伟 2020-05-09
sillion 2020-05-03
xiaobater 2020-05-01
ericasadun 2020-04-26
lynjay 2020-04-26
choupiaoyi 2020-04-26
tydldd 2020-04-23