Feedback
Did this article resolve your question/issue?

   

Article

Error "Incorrect datetime value: 'NULL' for column"

Information

 
TitleError "Incorrect datetime value: 'NULL' for column"
URL NameError-Incorrect-datetime-value-NULL-for-column
Article Number000184724
EnvironmentProduct: Connect(64) for ODBC MySQL Wire Protocol driver
Version: 07.16.0173
OS: All supported platforms
Database: MySQL
Application: All supported applications
Question/Problem Description
Stored procedure parameter NULL value is sent to the database as string literal 'NULL' instead of NULL.
Steps to Reproduce1. Create  table
CREATE TABLE t_date1 (F1 datetime(6) NULL,F2 datetime(6) NULL )

2. Create stored procedure
CREATE  PROCEDURE `sp_datetime_insert`(IN f1 DATETIME, IN f2 DATETIME)
BEGIN
 INSERT INTO t_date1 VALUES(f1, f2);
END

3. Prepare the stored procedure:
SQLPrepare: {call sp_datetime_insert(?,?)

4. Bind the parameters as NULL values:
SQLBindParameter:
StatementHandle = 0x003C4CB0, ParameterNumber = 1, InputOutputtype = SQL_PARAM_INPUT=1, ValueType = SQL_C_TIMESTAMP=11,
ParameterType = SQL_TIMESTAMP=11, ColumnSize = 19, DecimalDigits = 0, ParameterValuePtr = SQL_NULL_HANDLE, BufferLength = 16, StrLen_or_IndPtr = SQL_NULL_DATA=-1,
SQL_LEN_DATA_AT_EXEC = FALSE, Buffer Size = 600

SQLBindParameter:
In: StatementHandle = 0x003C4CB0, ParameterNumber = 2, InputOutputtype = SQL_PARAM_INPUT=1, ValueType = SQL_C_TIMESTAMP=11,
ParameterType = SQL_TIMESTAMP=11, ColumnSize = 19, DecimalDigits = 0, ParameterValuePtr = SQL_NULL_HANDLE, BufferLength = 16, StrLen_or_IndPtr = SQL_NULL_DATA=-1,
SQL_LEN_DATA_AT_EXEC = FALSE, Buffer Size = 600

Execure the stored procedure:
SQLExecute
Clarifying Information
Error Message[DataDirect][ODBC MySQL Wire Protocol driver][MySQL]Incorrect datetime value: 'NULL' for column 'f1' at row 1 (1292)
Defect NumberDefect 39963
Enhancement Number
Cause
The driver was sending the stored procedure parameter value NULL inside single quotes in error.
Resolution
Fixed in hot fix 07.16.0180.
Refer to article Connect and Connect64 for ODBC hot fix download and install instructions for instructions on how to download and install the hot fix.
Workaround
Notes
Last Modified Date11/20/2020 7:22 AM
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.