Precompilers and OCI (MOSC)

MOSC Banner

Using OCI to connect locally

edited May 8, 2015 7:30AM in Precompilers and OCI (MOSC) 6 commentsAnswered ✓

To run my application with a connect / as sysdba and SID environment variable set I would like to change the

connection string accordingly. The following is the code that connects via network (TNSNAMES):

DBConnect (char *server, char *username, char *password)
{
    sword status;
    int check_err ();
    /*------------------------------------------------------------------------*/
#ifndef TESTIT
    /*------------------------------------------------------------------------*/
    db_log = fopen ("db_log.txt", "w");
#else
    db_log=stdout;
#endif
    
    fprintf (db_log,"trying to CONNECT to server=%s user=%s password=%s>\n",server,username,password);
    t_0 = time (&db_time);

    /*------------------------------------------------------------------------*/
        status = check_err
                 (OCIInitialize (OCI_DEFAULT, 0, 0, 0, 0));
    /*------------------------------------------------------------------------*/
    if (status == 0)
    {
        status = check_err
                 (OCIEnvInit (&envhp, OCI_DEFAULT, 0, 0));
    }
    else
    {
        fprintf (db_log, "ERROR - OCIInitialize\n");
        return (1);
    }
    /*------------------------------------------------------------------------*/
    if (status == 0)
    {
        status = check_err
                 (OCIHandleAlloc (envhp, &errorhp, OCI_HTYPE_ERROR, 0, 0));
    }
    else
    {
        fprintf (db_log, "ERROR - OCIEnvInit in\n");
        return (1);
    }
    /*------------------------------------------------------------------------*/
    if (status ==

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center