Using OCI to connect locally
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 == 0