Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

RE: ODBC prepared statements to sybase 12.5 not working: msg#00157

db.tds.freetds

Subject: RE: ODBC prepared statements to sybase 12.5 not working


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>
Google Custom Search

Recently Viewed:
hardware.arm.at...    cms.citadel.dev...    video.gstreamer...    java.facelets.u...    misc.basics.qna...    web.wiki.instik...    network.uip.use...    xdg.devel/2003-...    tex.bibtex.bibd...    finance.quotesp...    ietf.zeroconf/2...    redhat.blinux.g...    suse.db2/2003-0...    php.phpesp/2004...    uml.devel/2003-...    gnome.labyrinth...    qnx.openqnx.dev...    boot-loaders.gr...    db.dataperfect....    audio.audacity....    linux.uclinux.m...    editors.j.devel...    os.openbsd.tech...    kde.users.multi...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive 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

Navigation