DB2 UDB Application Development client on AIX

Steve McAuliffe

DB2 UDB Application Development client on AIX
Bit of a vague question I'm afraid as this is a bit off my normal path, but hopefully someone can help.
I have installed DB2 AD client on an AIX box for some developers, it connects via a gateway on Linux to the host database on z/OS.
The install worked, and I have configured the connection and tested it ok.
However I have a developer asking what they need to put into there compile command in order to compile a C programme making an ODBC connection to the database.
I found the 'Connectivity cheat sheet for Application Developers (part 4)' which has a scenario for C connecting to a DB2 database using ODBC, unfortunately the example they give is from windows, with what looks like DB2 connect installed locally. As a result none of the files mentioned are found under AIX.
The developer is getting the following, if anyone can offer any help it would be most appreciated, do I need to install DB2 connect locally for the files?
listodbcdrivers.c
#include <stdio.h>
#include <sql.h>
#include <sqlext.h>
main()
{
SQLHENV env;
char driver[256];
char attr[256];
SQLSMALLINT driver_ret;
SQLSMALLINT attr_ret;
SQLUSMALLINT direction;
SQLRETURN ret;
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
direction = SQL_FETCH_FIRST;
while(SQL_SUCCEEDED(ret = SQLDrivers(env, direction,
driver, sizeof(driver), &driver_ret,
attr, sizeof(attr), &attr_ret)))
{
direction = SQL_FETCH_NEXT;
printf("%s - %s\n", driver, attr);
if (ret == SQL_SUCCESS_WITH_INFO) printf("\tdata truncation\n");
}
}
compiling command:
cc -I/usr/local/include listodbcdrivers.c -o listodbcdrivers -L/usr/local/lib -I/db2/home/taidv01/sqllib/include
Errors:
bash-2.05a$ cc -I/usr/local/include listodbcdrivers.c -o listodbcdrivers -L/usr/local/lib -I/db2/home/taidv01/sqllib/include
"/db2/home/taidv01/sqllib/include/sqlext.h", line 1681.1: 1506-166 (S) Definition of function SQLRETURN requires parentheses.
"/db2/home/taidv01/sqllib/include/sqlext.h", line 1681.11: 1506-276 (S) Syntax error: possible missing '{'?
"listodbcdrivers.c", line 7.3: 1506-045 (S) Undeclared identifier SQLHENV.
"listodbcdrivers.c", line 10.15: 1506-275 (S) Unexpected text driver_ret encountered.
"listodbcdrivers.c", line 10.3: 1506-045 (S) Undeclared identifier SQLSMALLINT.
"listodbcdrivers.c", line 11.15: 1506-275 (S) Unexpected text attr_ret encountered.
"listodbcdrivers.c", line 12.16: 1506-275 (S) Unexpected text direction encountered.
"listodbcdrivers.c", line 12.3: 1506-045 (S) Undeclared identifier SQLUSMALLINT.
"listodbcdrivers.c", line 13.13: 1506-275 (S) Unexpected text ret encountered.
"listodbcdrivers.c", line 13.3: 1506-045 (S) Undeclared identifier SQLRETURN.
"listodbcdrivers.c", line 15.52: 1506-045 (S) Undeclared identifier env.
"listodbcdrivers.c", line 15.18: 1506-045 (S) Undeclared identifier SQL_HANDLE_ENV.
"listodbcdrivers.c", line 15.34: 1506-045 (S) Undeclared identifier SQL_NULL_HANDLE.
"listodbcdrivers.c", line 16.54: 1506-045 (S) Undeclared identifier SQL_OV_ODBC3.
"listodbcdrivers.c", line 16.22: 1506-045 (S) Undeclared identifier SQL_ATTR_ODBC_VERSION.
"listodbcdrivers.c", line 18.3: 1506-045 (S) Undeclared identifier direction.
"listodbcdrivers.c", line 18.15: 1506-045 (S) Undeclared identifier SQL_FETCH_FIRST.
cc: 1501-230 Internal compiler error; please contact your Service Representative


Cheers,

Steve McAuliffe

IMS, DB2, CICS, WMQ for z/OS, WMB for z/OS
Mainframe Build
Network Computing Group
Tel: (020) 8760 6988
Internal: x 66988




Notice to recipient:
The information in this internet e-mail and any attachments is confidential and may be privileged. It is intended solely for the addressee. If you are not the intended addressee please notify the sender immediately by telephone. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.

When addressed to external clients any opinions or advice contained in this internet e-mail are subject to the terms and conditions expressed in any applicable governing terms of business or client engagement letter issued by the pertinent Bank of America group entity.

If this email originates from the U.K. please note that Bank of America, N.A., London Branch and Banc of America Securities Limited are authorised and regulated by the Financial Services Authority.

---------------------------------------------------------------------------------
Welcome to the IDUG DB2-L list. To unsubscribe, go to the archives and home page at http://www.idugdb2-l.org/archives/db2-l.html. From that page select "Join or Leave the list". The IDUG DB2-L FAQ is at http://www.idugdb2-l.org. The IDUG List Admins can be reached at [login to unmask email] Find out the latest on IDUG conferences at http://conferences.idug.org/index.cfm

Erick Wodarz

Re: DB2 UDB Application Development client on AIX
(in response to Steve McAuliffe)
You need the unix ODBC Driver manager found here. http://www.unixodbc.com/
< http://www.unixodbc.com/ > I'm guessing you've already installed this?

You should also point the header files to the provided ODBC header files
(this is how we did it when we ported our windows cli programs to a windows
ODBC program). The ODBC headers are largely the same as the provided db2
cli/odbc header files, but the differences/problems can be a little
maddening.

You should also link with the provided unix ODBC library. I've only done
this on windows, but it should work the same on AIX/Unix.

Erick

-----Original Message-----
From: DB2 Data Base Discussion List [mailto:[login to unmask email]On Behalf Of
McAuliffe, Stephen
Sent: Friday, December 08, 2006 7:41
To: [login to unmask email]
Subject: [DB2-L] DB2 UDB Application Development client on AIX


Bit of a vague question I'm afraid as this is a bit off my normal path, but
hopefully someone can help.
I have installed DB2 AD client on an AIX box for some developers, it
connects via a gateway on Linux to the host database on z/OS.

The install worked, and I have configured the connection and tested it ok.
However I have a developer asking what they need to put into there compile
command in order to compile a C programme making an ODBC connection to the
database.

I found the 'Connectivity cheat sheet for Application Developers (part 4)'
which has a scenario for C connecting to a DB2 database using ODBC,
unfortunately the example they give is from windows, with what looks like
DB2 connect installed locally. As a result none of the files mentioned are
found under AIX.

The developer is getting the following, if anyone can offer any help it
would be most appreciated, do I need to install DB2 connect locally for the
files?

listodbcdrivers.c
#include <stdio.h>
#include <sql.h>
#include <sqlext.h>
main()
{
SQLHENV env;
char driver[256];
char attr[256];
SQLSMALLINT driver_ret;
SQLSMALLINT attr_ret;
SQLUSMALLINT direction;
SQLRETURN ret;
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);
direction = SQL_FETCH_FIRST;
while(SQL_SUCCEEDED(ret = SQLDrivers(env, direction,
driver, sizeof(driver), &driver_ret,
attr, sizeof(attr), &attr_ret)))
{
direction = SQL_FETCH_NEXT;
printf("%s - %s\n", driver, attr);
if (ret == SQL_SUCCESS_WITH_INFO) printf("\tdata truncation\n");
}
}
compiling command:
cc -I/usr/local/include listodbcdrivers.c -o listodbcdrivers
-L/usr/local/lib -I/db2/home/taidv01/sqllib/include
Errors:
bash-2.05a$ cc -I/usr/local/include listodbcdrivers.c -o listodbcdrivers
-L/usr/local/lib -I/db2/home/taidv01/sqllib/include
"/db2/home/taidv01/sqllib/include/sqlext.h", line 1681.1: 1506-166 (S)
Definition of function SQLRETURN requires parentheses.
"/db2/home/taidv01/sqllib/include/sqlext.h", line 1681.11: 1506-276 (S)
Syntax error: possible missing '{'?
"listodbcdrivers.c", line 7.3: 1506-045 (S) Undeclared identifier SQLHENV.
"listodbcdrivers.c", line 10.15: 1506-275 (S) Unexpected text driver_ret
encountered.
"listodbcdrivers.c", line 10.3: 1506-045 (S) Undeclared identifier
SQLSMALLINT.
"listodbcdrivers.c", line 11.15: 1506-275 (S) Unexpected text attr_ret
encountered.
"listodbcdrivers.c", line 12.16: 1506-275 (S) Unexpected text direction
encountered.
"listodbcdrivers.c", line 12.3: 1506-045 (S) Undeclared identifier
SQLUSMALLINT.
"listodbcdrivers.c", line 13.13: 1506-275 (S) Unexpected text ret
encountered.
"listodbcdrivers.c", line 13.3: 1506-045 (S) Undeclared identifier
SQLRETURN.
"listodbcdrivers.c", line 15.52: 1506-045 (S) Undeclared identifier env.
"listodbcdrivers.c", line 15.18: 1506-045 (S) Undeclared identifier
SQL_HANDLE_ENV.
"listodbcdrivers.c", line 15.34: 1506-045 (S) Undeclared identifier
SQL_NULL_HANDLE.
"listodbcdrivers.c", line 16.54: 1506-045 (S) Undeclared identifier
SQL_OV_ODBC3.
"listodbcdrivers.c", line 16.22: 1506-045 (S) Undeclared identifier
SQL_ATTR_ODBC_VERSION.
"listodbcdrivers.c", line 18.3: 1506-045 (S) Undeclared identifier
direction.
"listodbcdrivers.c", line 18.15: 1506-045 (S) Undeclared identifier
SQL_FETCH_FIRST.
cc: 1501-230 Internal compiler error; please contact your Service
Representative


Cheers,

Steve McAuliffe

IMS, DB2, CICS, WMQ for z/OS, WMB for z/OS
Mainframe Build
Network Computing Group
Tel: (020) 8760 6988
Internal: x 66988




_____


Notice to recipient:
The information in this internet e-mail and any attachments is confidential
and may be privileged. It is intended solely for the addressee. If you are
not the intended addressee please notify the sender immediately by
telephone. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken or omitted to be taken in reliance on it,
is prohibited and may be unlawful.

When addressed to external clients any opinions or advice contained in this
internet e-mail are subject to the terms and conditions expressed in any
applicable governing terms of business or client engagement letter issued by
the pertinent Bank of America group entity.

If this email originates from the U.K. please note that Bank of America,
N.A., London Branch and Banc of America Securities Limited are authorised
and regulated by the Financial Services Authority.


_____

----------------------------------------------------------------------------
----- Welcome to the IDUG DB2-L list. To unsubscribe, go to the archives and
home page at http://www.idugdb2-l.org/archives/db2-l.html. From that page
select "Join or Leave the list". The IDUG DB2-L FAQ is at
http://www.idugdb2-l.org. The IDUG List Admins can be reached at
[login to unmask email] Find out the latest on IDUG conferences at
http://conferences.idug.org/index.cfm

---------------------------------------------------------------------------------
Welcome to the IDUG DB2-L list. To unsubscribe, go to the archives and home page at http://www.idugdb2-l.org/archives/db2-l.html. From that page select "Join or Leave the list". The IDUG DB2-L FAQ is at http://www.idugdb2-l.org. The IDUG List Admins can be reached at [login to unmask email] Find out the latest on IDUG conferences at http://conferences.idug.org/index.cfm