Вопрос

I try to connect to oracle with ocilib:

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

    OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);

    cn = OCI_ConnectionCreate("user", "db", "pass", OCI_SESSION_DEFAULT);
    st = OCI_StatementCreate(cn);

    OCI_ExecuteStmt(st, "select foo_id from foo");

    rs = OCI_GetResultset(st);

    while (OCI_FetchNext(rs))
    {
      printf("%i ", OCI_GetInt(rs, 1));
        //printf("%i - %s\n", OCI_GetInt(rs, 1), OCI_GetString(rs,2));
    }

    OCI_Cleanup();

    return EXIT_SUCCESS;

}

I'm getting ORA-12154. Do I need to set any paths? tnsnames.ora is valid.

Это было полезно?

Решение

First argument of OCI_ConnectionCreate should be the connection string (either an entry of the tnsnames.ora or an easy connect string)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top