|
|
Choosing A Webhost: |
RE: ODBC prepared statements to sybase 12.5 not working: msg#00157db.tds.freetds
Hi Freddy, Heres a patch that adds support for the missing statement attributes used by libobdc++. It helps libodbc++ get a lot further. Could you review it and apply to CVS? Cheers, Alex. Index: include/tdsodbc.h =================================================================== RCS file: /cvsroot/freetds/freetds/include/tdsodbc.h,v retrieving revision 1.40 diff -u -r1.40 tdsodbc.h --- include/tdsodbc.h 4 Aug 2003 15:14:08 -0000 1.40 +++ include/tdsodbc.h 8 Aug 2003 13:06:17 -0000 @@ -237,6 +237,8 @@ struct _sql_errors errs; char ard, ird, apd, ipd; SQLRETURN lastrc; + SQLUSMALLINT* row_status_ptr; + SQLUINTEGER* rows_fetched_ptr; }; struct _sql_param_info Index: src/odbc/odbc.c =================================================================== RCS file: /cvsroot/freetds/freetds/src/odbc/odbc.c,v retrieving revision 1.205 diff -u -r1.205 odbc.c --- src/odbc/odbc.c 5 Aug 2003 09:03:36 -0000 1.205 +++ src/odbc/odbc.c 8 Aug 2003 13:06:21 -0000 @@ -948,7 +948,9 @@ stmt->htype = SQL_HANDLE_STMT; stmt->hdbc = dbc; *phstmt = (SQLHSTMT) stmt; - + stmt->row_status_ptr = 0; + stmt->rows_fetched_ptr = 0; + ODBC_RETURN(dbc, SQL_SUCCESS); } @@ -1666,8 +1668,12 @@ cur = cur->next; } } - stmt->row++; + stmt->row++; + if ( stmt->row_status_ptr ) { + stmt->row_status_ptr[0] = SQL_ROW_NOROW; + } + ret = tds_process_row_tokens(stmt->hdbc->tds_socket, &rowtype, &computeid); if (ret == TDS_NO_MORE_ROWS) { tdsdump_log(TDS_DBG_INFO1, "SQLFetch: NO_DATA_FOUND\n"); @@ -1690,8 +1696,12 @@ tds_get_conversion_type(colinfo->column_type, colinfo->column_size), src, srclen, colinfo->column_bindtype, colinfo->column_varaddr, colinfo->column_bindlen); - if (len < 0) - ODBC_RETURN(stmt, SQL_ERROR); + if (len < 0) { + if ( stmt->row_status_ptr ) { + stmt->row_status_ptr[0] = SQL_ROW_ERROR; + } + ODBC_RETURN(stmt, SQL_ERROR); + } } if (colinfo->column_lenbind) { if (tds_get_null(resinfo->current_row, i)) @@ -1701,8 +1711,22 @@ } } if (ret == TDS_SUCCEED) { + + if ( stmt->rows_fetched_ptr ) { + (*(stmt->rows_fetched_ptr))++; + tdsdump_log(TDS_DBG_INFO1, "Got row (%d)\n", *(stmt->rows_fetched_ptr)); + + } + + if ( stmt->row_status_ptr ) { + stmt->row_status_ptr[0] = SQL_ROW_SUCCESS; + } ODBC_RETURN(stmt, SQL_SUCCESS); } else { + if ( stmt->row_status_ptr ) { + stmt->row_status_ptr[0] = SQL_ROW_ERROR; + } + tdsdump_log(TDS_DBG_INFO1, "SQLFetch: !TDS_SUCCEED (%d)\n", ret); ODBC_RETURN(stmt, SQL_ERROR); } @@ -1958,7 +1982,7 @@ break; case SQL_ATTR_ROW_NUMBER: - *ui_val = 0; /* TODO */ + *ui_val = (SQLUINTEGER)(stmt->row); break; case SQL_ATTR_USE_BOOKMARKS: @@ -1986,6 +2010,15 @@ *StringLength = sizeof(SQL_IS_POINTER); break; + case SQL_ATTR_ROW_STATUS_PTR: + *(SQLPOINTER *) Value = &stmt->row_status_ptr; + *StringLength = sizeof(SQL_IS_POINTER); + break; + case SQL_ATTR_ROWS_FETCHED_PTR: + *(SQLPOINTER *) Value = &stmt->rows_fetched_ptr; + *StringLength = sizeof(SQL_IS_POINTER); + break; + /* TODO ?? what to do */ case SQL_ATTR_FETCH_BOOKMARK_PTR: case SQL_ATTR_METADATA_ID: @@ -1996,9 +2029,7 @@ case SQL_ATTR_PARAMSET_SIZE: case SQL_ATTR_ROW_BIND_OFFSET_PTR: case SQL_ATTR_ROW_BIND_TYPE: - case SQL_ATTR_ROW_OPERATION_PTR: - case SQL_ATTR_ROW_STATUS_PTR: - case SQL_ATTR_ROWS_FETCHED_PTR: + case SQL_ATTR_ROW_OPERATION_PTR: case SQL_ATTR_SIMULATE_CURSOR: default: odbc_errs_add(&stmt->errs, "HY092", NULL, NULL); @@ -3154,6 +3185,21 @@ case SQL_ROWSET_SIZE: /* Always 1 */ break; + + case SQL_ATTR_ROW_STATUS_PTR: + stmt->row_status_ptr = (SQLUSMALLINT*) vParam; + break; + case SQL_ATTR_ROWS_FETCHED_PTR: + stmt->rows_fetched_ptr = (SQLUINTEGER*) vParam; + break; + case SQL_ATTR_ROW_ARRAY_SIZE: + if ( vParam != 1 ) { + tdsdump_log(TDS_DBG_INFO1, "odbc:SQLSetStmtOption: Attempt to set fetch size to %d. Only value of 1 supported\n", vParam); + odbc_errs_add(&stmt->errs, "HY092", NULL, NULL); + ODBC_RETURN(stmt, SQL_ERROR); + } + break; + case SQL_CURSOR_TYPE: if (vParam == SQL_CURSOR_FORWARD_ONLY) ODBC_RETURN(stmt, SQL_SUCCESS); -- Alex Hornby <alex@xxxxxxxxx>
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: Does SQLBindParameter work with SQLExecDirect, ZIGLIO Frediano |
|---|---|
| Next by Date: | RE: ODBC prepared statements to sybase 12.5 not working, ZIGLIO Frediano |
| Previous by Thread: | RE: ODBC prepared statements to sybase 12.5 not working, Alex Hornby |
| Next by Thread: | RE: ODBC prepared statements to sybase 12.5 not working, ZIGLIO Frediano |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |