C++使用 OCILIB 连接并操作 Oracle 数据库的代码

729 阅读1分钟
将开发过程较好的内容片段备份一次,如下内容是关于C++使用 OCILIB 连接并操作 Oracle 数据库的内容。 

#include "ocilib.h"
 
{
 
    OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
 
    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
    st = OCI_StatementCreate(cn);
 
    OCI_ExecuteStmt(st, "select intcol, strcol from table");
 
    rs = OCI_GetResultset(st);
 
    while (OCI_FetchNext(rs))
    {
        printf("%i - %sn"), OCI_GetInt(rs, 1), OCI_GetString(rs,2));
    }
 
    OCI_Cleanup();
 
    return EXIT_SUCCESS;
}