Bug #37649 Add support for data-at-execution with positioned insert/update
Submitted: 26 Jun 2008 1:04 Modified: 20 Feb 2009 13:28
Reporter: Hans Held Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:5.1 OS:Windows (MsWindows XP SP3)
Assigned to: Jess Balint CPU Architecture:Any
Tags: 5.1, error

[26 Jun 2008 1:04] Hans Held
Description:
When the program runs, it creates a new record in the database. While updating the database, an error occurs:

“[MySQL][ODBC 5.1 Driver][mysqld-5.0.45-community-nt]Column 'bodytxt_nl' cannot be null.”

But in fact, bodytxt_nl has the value “test”.

The error does not occur with MySQL connector/ODBC 3.51.

How to repeat:
To recreate this error you will need:
- my demo project(vb2005)
- my demo database (exported SQL).

I can't attach these files here, so please contact me: jheld@bcs.nl
[26 Jun 2008 1:21] Hans Held
[MySQL][ODBC 5.1 Driver][mysqld-5.0.45-community-nt]Column
'your_column' cannot be null.
[30 Jun 2008 23:31] Carter Wickstrom
Was getting the exact same error when performing this: 

INSERT INTO newMySqlTable SELECT foo, bar, '' as baz FROM oldMsSqlTable

Neither foo nor bar contained NULL values; all destination fields in newMySqlTable had NOT NULL constraints. The only field that failed the insert was a field of datatype text. When I changed the text field to a varchar(255), I was able to insert records without any errors.
[16 Jul 2008 5:35] Bogdan Degtyariov
Hello Hans,

I am responsible for resolving the current bug#37649.
Could you please send the test project at my email (bogdan@mysql.com)?
Thanks.
[16 Jul 2008 9:00] Bogdan Degtyariov
Thanks Hans,

I made the attachments invisible to public access.
[13 Aug 2008 7:08] Bogdan Degtyariov
Verified with MyODBC 5.1.4.
[13 Aug 2008 7:10] Bogdan Degtyariov
Works OK when disable SQL_API_SQLSETDESCFIELD flag.
[3 Oct 2008 14:28] Jess Balint
Merged to trunk, will be released in 5.1.6.
[10 Oct 2008 14:36] Tony Bedford
An entry was added to the 5.1.6 changelog:

Data-at-execution parameters were not supported during positioned update. This meant updating a long text field with a cursor update would erroneously set the value to null. This would lead to the error Column 'column_name' cannot be null while updating the database, even when column_name had been assigned a valid non-null string.
[19 Feb 2009 16:13] Luca Gallo
How can I disable this flag manually??thank you very much,
Luca
[19 Feb 2009 16:21] Tony Bedford
Assigning to myself as docs will need updating.
[20 Feb 2009 13:28] Tony Bedford
If you do not wish to use data-at-execution, simply remove the corresponding calls. For example:

SQLLEN ylen = SQL_LEN_DATA_AT_EXEC(10);
SQLBindCol(hstmt,2,SQL_C_BINARY, buf, 10, &ylen);

Would become:

SQLBindCol(hstmt,2,SQL_C_BINARY, buf, 10, NULL);

Note that in the call to SQLBindCol(), &ylen has been replaced by NULL.

For further information please refer to the MSDN documentation for SQLBindCol().

C/ODBC documentation updated accordingly.

Closing bug (again) and reassigning back to Jess Balint.