All Forums Connectivity
piotrs 10 posts Joined 08/09
07 Aug 2009
[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?

vhari 111 posts Joined 12/08
11 Aug 2009

What version Teradata ODBC Driver you are using ?

piotrs 10 posts Joined 08/09
11 Aug 2009

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

vhari 111 posts Joined 12/08
24 Aug 2009

ODBC driver version 12.00.00.02 has fix for this problem.

piotrs 10 posts Joined 08/09
25 Aug 2009

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

Did you mean 13.0.0.2?

piotrs 10 posts Joined 08/09
26 Aug 2009

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

You must sign in to leave a comment.