insert MS SQL server bigint from BaseX via sql:execute-prepared
Monday, 31 May 2021 · 3 messages
MH
Martin Honnen31 May 2021 16:05 #
I am trying to use BaseX to enter data from its XML db into an MS SQL server database, according to
https://docs.microsoft.com/en-us/sql/connect/jdbc/using-basic-data-types?view=sql-server-ver15 the MS SQL server column type bigint is mapped to long in Java.
However, when I try
<sql:parameter type="long">{$id}</sql:parameter>with BaseX and
sql:execute-prepared, I get an error saying [sql:error] An SQL exception occurred: unsupported type: long
The BaseX documentation
https://docs.basex.org/wiki/SQL_Module#sql:execute-prepared indeed only lists
attribute type { "int" | "string" | "boolean" | "date" | "double" | "float" | "short" | "time" | "timestamp" | "sqlxml" }
as the possible types. Am I out of luck trying to use BaseX that way for that datatype? Using <sql:parameter type="int">{$id}</sql:parameter> the sql doesn't succeed.CG
Christian Grün31 May 2021 18:01 #
Hi Martin,
I have added "long" to the list of supported data types, as well as "byte" and "bigdecimal" [1]. I hope it works as expected. A new snapshot is available [2]; your feedback is welcome
Cheers,
Christian
[1] https://github.com/BaseXdb/basex/commit/d3385eb787010d78a0a0176d84ca492ced769952 [2] https://files.basex.org/releases/latest/
Quoted text · Martin Honnen · 18 lines
On Mon, May 31, 2021 at 4:05 PM Martin Honnen <martin.honnen at gmx.de> wrote: > > > I am trying to use BaseX to enter data from its XML db into an MS SQL server database, according to https://docs.microsoft.com/en-us/sql/connect/jdbc/using-basic-data-types?view=sql-server-ver15 the MS SQL server column type bigint is mapped to long in Java. > > However, when I try > > <sql:parameter type="long">{$id}</sql:parameter> > > with BaseX and sql:execute-prepared, I get an error saying [sql:error] An SQL exception occurred: unsupported type: long > > The BaseX documentation https://docs.basex.org/wiki/SQL_Module#sql:execute-prepared indeed only lists > > > attribute type { "int" | "string" | "boolean" | "date" | "double" | > "float" | "short" | "time" | "timestamp" | "sqlxml" } > > as the possible types. Am I out of luck trying to use BaseX that way for that datatype? Using <sql:parameter type="int">{$id}</sql:parameter> the sql doesn't succeed.
MH
Martin Honnen31 May 2021 21:03 #
Quoted text · Christian Grün · 4 lines
On 31.05.2021 18:01, Christian Grün wrote: > I have added "long" to the list of supported data types, as well as > "byte" and "bigdecimal" [1]. I hope it works as expected. A new > snapshot is available [2]; your feedback is welcome
Looks great, thanks a (put some bigint here) lot. Turns out my real data is not yet in shape for what I had planned but at least the long/bigint column insertion works fine.
Written for BaseX 9.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery