I'm trying to build a c++ application to use ODBC with MaxDB and I'm finding
the ODBC Manual for MaxDB a little difficult to follow.
I have been trying to use:
#include "/opt/sapdb/indep_prog/incl/WINDOWS.H"
#include "/opt/sapdb/indep_prog/incl/sql.h"
#include "/opt/sapdb/indep_prog/incl/sqlext.h"
#include <iostream>
class ODBC_Class{
public:
SQLHANDLE EnvHandle;
SQLHANDLE ConnHandle;
SQLRETURN ReturnCode;
public:
ODBC_Class();
~ODBC_Class();
};
/**********************************************/
ODBC_Class::ODBC_Class(){
ReturnCode = SQL_SUCCESS;
ReturnCode = SQLAllocHandle(SQL_HANDLE_ENV,
SQL_NULL_HANDLE,
&EnvHandle);
if(ReturnCode == SQL_SUCCESS){
ReturnCode = SQLSetEnvAttr(EnvHandle,
SQL_ATTR_ODBC_VERSION,
(SQLPOINTER) SQL_OV_ODBC3,
SQL_IS_UINTEGER);
}//if
if(ReturnCode == SQL_SUCCESS){
ReturnCode = SQLAllocHandle(SQL_HANDLE_DBC,
EnvHandle,
&ConnHandle);
}//if
}//ODBC_Class
/*--------------------------------------------*/
ODBC_Class::~ODBC_Class(){
if(ConnHandle != NULL){
SQLFreeHandle(SQL_HANDLE_DBC, ConnHandle);
}//if
if(EnvHandle != NULL){
SQLFreeHandle(SQL_HANDLE_ENV, EnvHandle);
}//if
}//~ODBC_Class
/*--------------------------------------*/
int main(){
SQLRETURN ReturnCode = SQL_SUCCESS;
//ODBC_Class Example;
return(ReturnCode);
}//main
and when I: g++ -o odbctest odbctest.cpp
I get:
/tmp/cc4SE4V9.o(.text+0x1f): In function
`ODBC_Class::ODBC_Class[not-in-charge]()':
: undefined reference to `SQLAllocHandle'
/tmp/cc4SE4V9.o(.text+0x46): In function
`ODBC_Class::ODBC_Class[not-in-charge]()':
: undefined reference to `SQLSetEnvAttr'
/tmp/cc4SE4V9.o(.text+0x70): In function
`ODBC_Class::ODBC_Class[not-in-charge]()':
: undefined reference to `SQLAllocHandle'
/tmp/cc4SE4V9.o(.text+0x9f): In function
`ODBC_Class::ODBC_Class[in-charge]()':
: undefined reference to `SQLAllocHandle'
/tmp/cc4SE4V9.o(.text+0xc6): In function
`ODBC_Class::ODBC_Class[in-charge]()':
: undefined reference to `SQLSetEnvAttr'
/tmp/cc4SE4V9.o(.text+0xf0): In function
`ODBC_Class::ODBC_Class[in-charge]()':
: undefined reference to `SQLAllocHandle'
/tmp/cc4SE4V9.o(.text+0x11b): In function `ODBC_Class::~ODBC_Class
[not-in-charge]()':
: undefined reference to `SQLFreeHandle'
/tmp/cc4SE4V9.o(.text+0x135): In function `ODBC_Class::~ODBC_Class
[not-in-charge]()':
: undefined reference to `SQLFreeHandle'
/tmp/cc4SE4V9.o(.text+0x159): In function `ODBC_Class::~ODBC_Class
[in-charge]()':
: undefined reference to `SQLFreeHandle'
/tmp/cc4SE4V9.o(.text+0x173): In function `ODBC_Class::~ODBC_Class
[in-charge]()':
: undefined reference to `SQLFreeHandle'
collect2: ld returned 1 exit status
So I believe these methods are not part of the Core, Level1 and Level2
conformance of the MaxDB ODBC calls.
In fact they are not in the Manual, so I guess I need to use SQLAllocEnv
which is listed, but without the signature(parameters), so I'm a little
stuck.
If I'm reading the manual correctly, it looks like MaxDB is ODBC 3.5
compliant, however SQLAllocHandle is not there. Is it possible to be ODBC
3.5 and yet not have these calls as part of the interface.
Im still trying to learn all the in's and out's of ODBC so plz don't flame
me, I'm just looking for a little help understanding what I need to do.
Thank you for your time, I hope to learn this well enough to help others in
the future.
Steve
PS I did look in the email archives and found :
SQLDBC example - Sean Mollet, April 28 2004 2:53pm
which I believe further confirms what I'm trying to convey in this
question.