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. Is it possible to get a code snipet for a simple connection.
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;
/**********************************************/
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 apparantly this methods are not part of the Core, Level1 and Level2 conformance of the MaxDB ODBC calls.
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 you precious time, I hope to learn this well enough to help others in the future.
Steve
> and when I: g++ -o odbctest odbctest.cpp
Where do you specify the ODBC-library?
Something like <ODBC_installdir>/lib/libsqlod.a
is missing.
HTH Thomas
Add a comment