Skip to content

Oracle ODBC: get(T) caused exception "bad cast" #1077

Closed Answered by zann1x
330305020 asked this question in Q&A
Discussion options

You must be logged in to vote

With type_conversions, you're using SOCI's dynamic API. This API forces you to use the exact C++ data types that SOCI maps the database types to (see https://soci.sourceforge.net/doc/release/4.0/backends/odbc/#dynamic-binding).

While it is true that you're creating the column id as type integer, you have to keep in mind that you also created a primary key constraint on that column. Some databases treat such columns as something along the lines of numeric(38,0) internally, which of course would get mapped from SQL_NUMERIC to double by SOCI. I don't know how Oracle handles primary keys, but based on your description I would assume that this is exactly the issue here. Retrieving the column as

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@330305020
Comment options

Answer selected by 330305020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants