Comments - MariaDB ODBC 3.2.2 insert zero date for empty strings

2 weeks, 5 days ago Ian Gilfillan

If you need to retrieve them as NULL, you could insert them as NULL, either explicitly, or by setting the default value to NULL:

CREATE OR REPLACE TABLE t1 (id INT, dt DATETIME DEFAULT NULL);
       
INSERT INTO t1(id) VALUES (1);

SELECT * FROM t1;             
+------+------+
| id   | dt   |
+------+------+
|    1 | NULL |
+------+------+
 
2 weeks, 2 days ago tahir dange

Thank you for your quick response! Ideally, we should avoid explicitly converting values to NULL, as the insertion logic was established from the beginning, and we prefer not to modify it. This logic was specifically designed for all ODBC supported data bases. Is there a way to insert empty string records as NULL without altering the insert query? The current query works as expected with driver version 3.1.20, but later versions convert empty strings to zero dates. We have parsing logic that processes the retrieved dates, and while NULL values pose no issue, zero dates cause the logic to fail.

To prevent this, we need to ensure that retrieved dates are either NULL or empty strings, but not zero dates.

 
2 weeks, 2 days ago Ian Gilfillan

If you're not inserting in the way given by the example above, how are you inserting an "empty value"? Please provide your insert string, table structure, server version, and value of the SQL_MODE variable so we can see what you're doing currently.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.