Exemplo n.º 1
0
int main(void)
{
   OCI_Connection *cn;

   if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
        return EXIT_FAILURE;

    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
    evt = CreateEvent(0, TRUE, FALSE, 0);

    _beginthread(long_oracle_call, 0, cn);

    if (WaitForSingleObject(evt, 10000) != WAIT_OBJECT_0)
    {
        OCI_Break(cn);
        Sleep(2000);
    }

    OCI_Cleanup();

 
    return EXIT_SUCCESS;
}
Exemplo n.º 2
-1
int main(void)
{
    OCI_Connection *cn;
    OCI_Statement *st;
    OCI_Thread *th;

    if (!OCI_Initialize(NULL, NULL, OCI_ENV_THREADED | OCI_ENV_CONTEXT))
    {
        return EXIT_FAILURE;
    }

    th = OCI_ThreadCreate();
    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
    st = OCI_StatementCreate(cn);

    OCI_ThreadRun(th, long_oracle_call, st);

    sleep(1);
    OCI_Break(cn);

    OCI_ThreadJoin(th);
    OCI_ThreadFree(th);

    OCI_StatementFree(st);
    OCI_ConnectionFree(cn);
    OCI_Cleanup();

    return EXIT_SUCCESS;
}