on 09-20-2008 4:32 PM
I want help on the sequence of calls after SQLDBC_ResultSet_bindColumn to retrieve the data from the bound columns.
I am working with the HOTEL.CITY table which has 3 columns: Below is main section of my code. When I use the SQLDBC_ResultSet_getObject function inside the while loop everything works fine and i get the result of seeing all the columns on my screen. But this works even without doing the SQLDBC_ResultSet_bindColumn.
So, my question is after we do the bind, what sequence of call am i supposed to do next to achieve the same result. I assume we don't have to call "SQLDBC_ResultSet_getObject" as before.
Kindly Help......
char *stmtstr = "SELECT ZIP,NAME,STATE from HOTEL.CITY";
rc = SQLDBC_PreparedStatement_prepare(stmt, stmtstr, strlen(stmtstr),encodAsciiType );
rc = SQLDBC_PreparedStatement_executeASCII(stmt);
SQLDBC_ResultSet *result;
result = SQLDBC_PreparedStatement_getResultSet(stmt);
char szString[30];
SQLDBC_Length ind;
char szString2[40];
SQLDBC_Length ind2;
char szString3[30];
SQLDBC_Length ind3;
SQLDBC_HostType htype = SQLDBC_HOSTTYPE_ASCII;
SQLDBC_ResultSet_bindColumn(result, 1, htype, szString, &ind, sizeof(szString), SQLDBC_TRUE);
SQLDBC_ResultSet_bindColumn(result, 2, htype, szString2, &ind2, sizeof(szString2), SQLDBC_TRUE);
SQLDBC_ResultSet_bindColumn(result, 3, htype, szString3, &ind3, sizeof(szString3), SQLDBC_TRUE);
int RowNum = 1;
while ( (rc = SQLDBC_ResultSet_next(result)) == SQLDBC_OK) {
rc = SQLDBC_ResultSet_getObject(result, 1, SQLDBC_HOSTTYPE_ASCII, szString,&ind, sizeof(szString),SQLDBC_TRUE);
printf("%s\n", szString);
rc = SQLDBC_ResultSet_getObject(result, 2, SQLDBC_HOSTTYPE_ASCII, szString2,&ind2, sizeof(szString2),SQLDBC_TRUE);
printf("%s\n", szString2);
rc = SQLDBC_ResultSet_getObject(result, 3, SQLDBC_HOSTTYPE_ASCII, szString3,&ind3, sizeof(szString3),SQLDBC_TRUE);
printf("%s\n", szString3);
}
Regards
Raja
Yes, it is the rowset. The rowset is an implicit object on the result
set. You only have to go one way around and call
SQLDBC_ResultSet_getRowSet to get the (implicit) row set. The row set is tied to the result set, and unless you set the size of it or use
updatable row sets, there shouldn't be much to worry.
Regards
Alexander
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
SQLDBC_ResultSet_fetch must be called to move data into the
bound columns. The next method, and the other navigational
methods for scrollable result sets (first, last, absolute, relative, ...) just move the cursor. This is more fine-grained as ODBC ...
Regards
Alexander
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexander,
In the SQLDBC_C.h file there no function with name SQLDBC_ResultSet_fetch. There is one with SQLDBC_RowSet_fetch though. Did you mean this one ?
Is it necessary to use RowSet whenever we use binding of Result Set columns ? I am little unwilling to use RowSet in my application, as it will mean additional checks and code.
Kindly Help.
Regards
Raja
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.