Issue when using SQLExecDirect against Oracle DSN

Hi all,

Im having an issue when executing SQLExecDirect function in the code below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
    SQLHANDLE handle;
    //SQLSMALLINT type;
    SQLHENV env;
    SQLHDBC dbc;
    SQLHSTMT stmt;
    SQLRETURN ret;
    SQLCHAR conn[256] = 
     "DSN=MY_DSN;UID=user;PWD=pwd;";
 //Allocate and environment handle
 SQLAllocHandle (SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
 //ODBC 3 support
 SQLSetEnvAttr (env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
 //Allocate a connection handle
 SQLAllocHandle (SQL_HANDLE_DBC, env, &dbc);
 //Connect to the DSN 
 ret = SQLDriverConnect(dbc, NULL, conn, SQL_NTS, outstr, sizeof (outstr), &outstrlen, SQL_DRIVER_NOPROMPT);
 if (SQL_SUCCEEDED(ret)){
  outfile1<<"SQLDriverConnect succeded"<<endl;
  //Allocate Statement handle
  ret = SQLAllocHandle (SQL_HANDLE_STMT, dbc, &stmt);
  if (SQL_SUCCEEDED(ret)){
   outfile1<<"Statement handle allocated"<<endl;
   //Execute Query
   ret = SQLExecDirect(stmt, (unsigned char*)"SELECT * FROM SCHEMA.USER_TABLE", SQL_NTS);
   if (SQL_SUCCEEDED(ret)){
    outfile1<<"Execute query succeded"<<endl;
    outfile1.close();
    return (SecurityErrOK);
   } else{
    outfile1<<"Execute query failed"<<endl;
    outfile1.close();
    return (SecurityErrNoSuchUser);
   }
  } else{
   outfile1<<"Handle allocation failed"<<endl;
   outfile1.close();
   return (SecurityErrNoSuchUser);
  }
    } else{
  outfile1<<"SQLDriverConnect failed"<<endl;
  outfile1.close();
     return (SecurityErrNoSuchUser);
 }


I have no issues in connecting to the dsn and allocating the sql statement as shown in the logged file:

SQLDriverConnect succeded
Statement handle allocated

But for some reason the execution stops at SQLExecDirect. No line is written in the dump file and ret value cannot be accessed. I am connecting to an Oracle DB from an application than runs in Windows 2008 R2. I dont really know how I can debug this further.

Any comments or tips would be highly appreciated.

Thanks in advance,


Last edited on
Topic archived. No new replies allowed.