Unix Technical Forum

Mixing SQL_LEN_DATA_AT_EXEC, 0, and SQL_NULL_DATA with SQLPrepare

This is a discussion on Mixing SQL_LEN_DATA_AT_EXEC, 0, and SQL_NULL_DATA with SQLPrepare within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> Can anybody tell me if I am doing something wrong here, or, can Microsoft verify if this is a ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > MS SQL ODBC

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 09:03 PM
=?Utf-8?B?SmltIEZsb29k?=
 
Posts: n/a
Default Mixing SQL_LEN_DATA_AT_EXEC, 0, and SQL_NULL_DATA with SQLPrepare

Can anybody tell me if I am doing something wrong here, or, can Microsoft
verify if this is a bug in SQL Server?

If I prepare a simple insert, for example, "INSERT INTO MYTABLE(MYCOL)
VALUES (?)", and then, bind an SQL_LONGVARCHAR column, for example:

SQLBindParameter(hstmt, 1, 1, 1, -1, 2147483647, 0, data, 0, &indicator);

then, if I set the ODBC environment attribute SQL_ATTR_ODBC_VERSION to
SQL_OV_ODBC2, I can choose between SQL_LEN_DATA_AT_EXEC(length) (and use
SQLPutData), 0, and SQL_NULL_DATA for the indicator, each time I call
SQLExecute (after SQLPrepare).

If I set SQL_OV_ODBC3, mixing these indicators causes "Invalid Cursor
State", when using SQLPrepare + SQLExecute (vs. SQLExecDirect).

1. Prepare the statement and bind.

2. Set the indicator to SQL_LEN_DATA_AT_EXEC(some length > 0) and use
SQLExecute, SQLParamData, SQLPutData, SQLParamData to send the bytes.

3. Now try to set the indicator to 0 (or, SQL_NULL_DATA). If that succeeds,
try sending another row with length > 0. With SQL Server 2000, 8.00.2039, I
get "Invalid Cursor State".

If I set SQL_LEN_DATA_AT_EXEC(0) I can then SQLPutData 0 bytes, but if I
want to send SQL_NULL_DATA, I have to either: (1) set
SQL_LEN_DATA_AT_EXEC(0), and SQLPutData SQL_NULL_DATA, which IMHO does not
follow the ODBC spec, or (2) use SQLExecDirect, or (3) use SQL_OV_ODBCV2.

Regards,
Jim Flood
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:57 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com