C语言 ocilib字符串绑定

int main(){
    OCI_Connection *cn;
    OCI_Statement  *st;
    OCI_Resultset  *rs;

    if (!OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT))
    {
        return EXIT_FAILURE;
    }

    cn = OCI_ConnectionCreate("127.0.0.1:1521/orcl", "game", "game", OCI_SESSION_DEFAULT);
    st = OCI_StatementCreate(cn);

    // 根据序列号查询设备信息 eid类型为VARCHAR(10)
    OCI_Prepare(st, "select eid from EQUIPMENT where EID = :eid");
    OCI_BindString(st, ":eid", "参数", 10);            // 第三个参数的类型为otext
    OCI_Execute(st);

    rs = OCI_GetResultset(st);

    // 输出返回结果
    if(OCI_FetchNext(rs))
        printf("eid : %s\n", OCI_GetString(rs, 1));
    else
        printf("没有返回值");

    // 释放资源
    OCI_StatementFree(st);
    OCI_ConnectionFree(cn);
    OCI_Cleanup();

    return EXIT_SUCCESS;
}


你可能感兴趣的:(C语言 ocilib字符串绑定)