<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}
p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>Hi everybody!<br></div><div><br></div><div>I have noticed that the ODBC driver in the OTP, encodes the SQL type TIMESTAMP as a tuple {{YY, MM, DD}, {HH, MM, SS}} (see [1], [2]). But according to the Microsoft ODBC documentation [3] the structure SQL_C_TYPE_TIMESTAMP also has a "fraction" field for sub-second resolution.<br></div><div><br></div><div>Would it be possible to change how the ODBC data types maps to Erlang terms? A quick hack as the one listed below seems to do the job for my specific use case.<br></div><div><br></div><div>Best wishes,<br></div><div>Andrea<br></div><div><br></div><div>diff --git a/lib/odbc/c_src/odbcserver.c b/lib/odbc/c_src/odbcserver.c<br></div><div>index ee5dc9cd0a..dbd49b2836 100644<br></div><div>--- a/lib/odbc/c_src/odbcserver.c<br></div><div>+++ b/lib/odbc/c_src/odbcserver.c<br></div><div>@@ -1490,10 +1490,11 @@ static void encode_column_dyn(db_column column, int column_nr,<br></div><div>             ei_x_encode_ulong(&dynamic_buffer(state), ts->year);<br></div><div>             ei_x_encode_ulong(&dynamic_buffer(state), ts->month);<br></div><div>             ei_x_encode_ulong(&dynamic_buffer(state), ts->day);<br></div><div>-            ei_x_encode_tuple_header(&dynamic_buffer(state), 3);<br></div><div>+            ei_x_encode_tuple_header(&dynamic_buffer(state), 4);<br></div><div>             ei_x_encode_ulong(&dynamic_buffer(state), ts->hour);<br></div><div>             ei_x_encode_ulong(&dynamic_buffer(state), ts->minute);<br></div><div>             ei_x_encode_ulong(&dynamic_buffer(state), ts->second);<br></div><div>+            ei_x_encode_ulong(&dynamic_buffer(state), ts->fraction);<br></div><div>             break;<br></div><div>        case SQL_C_CHAR:<br></div><div>                if binary_strings(state) {<br></div><div><br></div><div><br></div><div>[1] <a href="https://erlang.org/doc/apps/odbc/databases.html#type">https://erlang.org/doc/apps/odbc/databases.html#type</a><br></div><div>[2] <a href="https://github.com/erlang/otp/blob/3102ec010e74508f53e9ff0233b090b8c0334a76/lib/odbc/c_src/odbcserver.c#L1486">https://github.com/erlang/otp/blob/3102ec010e74508f53e9ff0233b090b8c0334a76/lib/odbc/c_src/odbcserver.c#L1486</a><br></div><div>[3] <a href="https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/c-data-types?view=sql-server-ver15">https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/c-data-types?view=sql-server-ver15</a><br></div><div><br></div><div id="sig21437841"><div>--<br></div><div>Andrea Bedini<br></div><div><a href="http://www.andreabedini.com">http://www.andreabedini.com</a><br></div><div>use <a href="http://keybase.io/andreabedini">keybase.io/andreabedini</a> to send me private messages<br></div><div><br></div><div><br></div></div><div><br></div></body></html>