[erlang-questions] ODBC SQL_BIGINT type

Jan Chochol jan.chochol@REDACTED
Wed Sep 4 08:58:48 CEST 2019

Hi Tyson,

Reason for using SQL_C_CHAR as physical encoding for SQL_BIGINT is,
that there are not much better options.
You can use SQL_C_NUMERIC, but it will not help in your case (it is
still string containing digits plus some metainformation).

Reason for not using SQL_C_SBIGINT or SQL_C_UBIGINT is, that it is not
possible to found if SQL_BIGINT is signed, or unsigned, so it can lead
to situation, that some values could not be returned. And it also
requires ODBC 3.0, which is not supported by all drivers.

What can Erlang ODBC client do, is to encode returned SQL_C_CHAR to
number, but it can affect backward compatibility (it can be
implemented in configurable way).

>From my point of view, problem is that Erlang ODBC implementation
tries to simplify interface too much, so it can not be used in some
Most problematic part is, that it does not return type information
about columns (there is 'odbc:describe_table/2', but it can not be
used in all cases for all requests), and different column types are
encode to same Erlang type (we had own problems with distinguishing
between SQL_WCHAR and SQL_CHAR).
I do not see any easy way to fix this - it would probably require
complete rewrite of Erlang ODBC client.

On the other way - other languages have also big problems with ODBC -
e.g. Perl DBD::ODBC has quite a lot problems with Unicode.

Jan Chochol

On Tue, Sep 3, 2019 at 3:13 PM Tyson Buzza <tyson.buzza@REDACTED> wrote:
> Does anyone know why the ODBC SQL_BIGINT is implemented as SQL_C_CHAR? There must be a reason for it, but this code is 10 years old so I'm not sure who to ask. I'm wondering if the original reason would even be relevant anymore.
> I'm currently writing an Ecto adapter using ODBC and this is making it difficult. If you use a big int in your schema, Ecto expects an integer and gets a string instead. Either way the solution is to create a cache holding the type information and parse the string if a number is expected. I'm just wondering if this can be fixed for other people with my problem in the future.
> I'm talking about this file https://github.com/erlang/otp/blob/master/lib/odbc/c_src/odbcserver.c
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list