[ODBC] Inserting null value for TIMESTAMP column, using arrays of parameters

Connectivity
N/A

[ODBC] Inserting null value for TIMESTAMP column, using arrays of parameters

Hello!

I've a problem when inserting null value to TIMESTAMP column. I use arrays of parameters and insert two rows with one statement. I receive error when executing statement: "Invalid timestamp".

Problem occurs only when one row has value and other is null. If two has value or are null, then problem doesn't occur. There is no problems in similar situation with another data types (e.g. VARCHAR, INTEGER).

Here is my code (without error handling etc.):


SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)2, 0);

SQLPrepare(hstmt, (SQLCHAR*)"INSERT INTO Limity(trzy, piec, szesc) VALUES('123', 'abcde', ?)", SQL_NTS);

SQLSMALLINT sqlDataType, decDigits, nullable;
SQLULEN size;
SQLDescribeParam(hstmt, 1, &sqlDataType, &size, &decDigits, &nullable);

SQL_TIMESTAMP_STRUCT tsStruct[2];

tsStruct[1].year = 2008;
tsStruct[1].month = 8;
tsStruct[1].day = 3;
tsStruct[1].hour = 0;
tsStruct[1].minute = 0;
tsStruct[1].second = 0;
tsStruct[1].fraction = 0;

SQLINTEGER lenInd[2];
lenInd[0] = SQL_NULL_DATA;
lenInd[1] = 0;

SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_TYPE_TIMESTAMP, sqlDataType, size, decDigits, tsStruct, 16, lenInd);

SQLExecute(hstmt);


This work fine with MS SQL Server. Maybe this is driver bug?
5 REPLIES
Teradata Employee

Re: [ODBC] Inserting null value for TIMESTAMP column, using arrays of parameters


What version Teradata ODBC Driver you are using ?

N/A

Re: [ODBC] Inserting null value for TIMESTAMP column, using arrays of parameters

I'm connecting to Teradata Express Edition 12.0 using ODBC driver 12.00.00.01
Teradata Employee

Re: [ODBC] Inserting null value for TIMESTAMP column, using arrays of parameters


ODBC driver version 12.00.00.02 has fix for this problem.

N/A

Re: [ODBC] Inserting null value for TIMESTAMP column, using arrays of parameters

I can't see such version here: http://www.teradata.com/DownloadCenter/Group89.aspx

Did you mean 13.0.0.2?
N/A

Re: [ODBC] Inserting null value for TIMESTAMP column, using arrays of parameters

OK, after logging in I find it. It helped, thank you!