ODBC Callback - SxsSQLGetData()

This program is a part of map in function using ODBC Callback.

sqr = SxsSQLPrepare (statementHandle, “select * from emp;”);

int ret = SxsSQLExecute (statementHandle);
sqr = SxsSQLFetch (statementHandle);

int bufferLength = 100;
byte resBuffer = new byte [bufferLength];
IntRef resIndicator = new IntRef (10000);
short colNo = 2;

sqr = SxsSQLGetData (statementHandle, colNo, SQL_C_CHAR, resBuffer, bufferLength,resIndicator);

Now this program works fine.
The problem is,
1. the query that i gave gives multiple rows and columns. But in the SxsSQLGetData() method column no. has to be specified so, i can’t address multiple columns.

2. the 2nd column(with respect to this program) contains multiple rows. But byte array is storing only the first record and some unknown data leaving remaining rows.

OUTPUT:-
sha Q _Java_com_softwareag_ino_sxs_ASXJBase_n_1SxsSQLGetData@36 e m p

i need a solution to address multiple rows and columns.

To achieve your goal you should use SxsSQLBindCol. Attached is a code snippet containing a query function which returns a given number of rows from a table with 3 columns (nkey, name, phone).

I hope it makes clear how to use SxsSQLBindCol to get multiple rows.

Regards

Julius Geppert
Quality Engineer Tamino
Software AG
fetch_n_rows_snippet.java (4.19 KB)

Hello sha,

To get multiple columns, you have to call SxsSQLGetData() multiple times with the number of each column you want.

With SxsSQLFetch() you can switch to the next row in the result set. SxsSQLGetData() always gives you the column values of the actual row.

I confess, this is a little bit tedious, but ODBC is defined that way.

I hope this will also help, Gernot