smalldatetime/timestamp not supported?
Closed this issue · 4 comments
It seems that there is no Implementation of OutputParameter
like:
let mut buf = odbc_sys::Timestamp {year:0, month:0, day:0, hour:0, minute:0, second:0, fraction:0 };
match row.get_data(colNo, &mut buf) {
...
Is the a different way to exttract smalldatetime / timestamp and datetime2?
Yeah, I did not get around to implement OutputParameter
for Timestamp
yet. Are you interessted in fetching only a singe value from the Database, or do you want to fetch an entire column?. Do you only wanna fetch a timestamp, or does the row contain other fields?
Anyhow you can fetch dates using ColumnarBuffer
. To get an idea how to fetch data using it see: https://docs.rs/odbc-api/latest/odbc_api/guide/index.html#fetching-results-column-wise-with-columnarbuffer
Selecting BufferKind::Timestamp
will allow you to access the column as a silce &[Timestamp]
or a NullableSlice<Timestamp>
depending on the Nullability
of the column.
Here is also a test fetching them:
odbc-api/odbc-api/tests/integration.rs
Line 677 in 7c578c3
Thank you for the explanation! Currently I still fetch row by row, field by field, because the column binding api needs more rust know how.
I see that you added something that might help fetching timestamps without ColumnarBuffer....
... because the column binding api needs more rust know how.
true
I see that you added something that might help fetching timestamps without ColumnarBuffer....
Just started releasing odbc-api 0.52.0
. Should allow you to use timestamps directly with get_data
. It lowers the requirements of get_data
rather than implementing OutputParameter
for Timestamp
. Reason being, there isn't a good default relational type for Timestamp
because of some ambigiouty in the precision. Tl;dr: the code you tried will work in version 0.52.0
.
Closing this issue since timestamps can now be fetched using get_data