JuliaDatabases / ODBC.jl

An ODBC interface for the Julia programming language
https://odbc.juliadatabases.org/stable
Other
106 stars 63 forks source link

ODBC prepared insert into MS SQL Server failing #307

Closed ltf-canada closed 3 years ago

ltf-canada commented 4 years ago

Up until this past weekend, I was able to insert new rows into a SQL Server database as shown below but now it is failing with the following MS ODBC error message:

HY104: [Microsoft][ODBC SQL Server Driver]Invalid precision value

The code to do the insert is as follows:

`const NRTABLE = "dbo.TimeRanges" if DBINSERT prepstr = string("INSERT INTO ", NRTABLE, " (testid, rangestart, rangeend, rangename) VALUES(?, ?, ?, ?)") inscmd = DBInterface.prepare(ltdsnr, prepstr) for drow ∈ eachrow(testrangesdf) DEBUG && println((drow.testid, drow.rangestart, drow.rangeend, drow.rangename))

DEBUG && dump(drow)

        DBInterface.execute(inscmd, (drow.testid, drow.rangestart, drow.rangeend, drow.rangename))
    end
    @info(string("Marked named ranges for test ", tid, " in PerfSite."))
end

`

The first row I'm trying to insert is:

(26225, DateTime("2020-07-16T08:46:20"), DateTime("2020-07-16T12:07:00"), "Compliance")

I haven't been able to isolate exactly what has changed since last week when this worked nicely. Possibilities include Tables.jl, DataFrames.jl, and the MS ODBC driver. I don't believe that ODBC has been changed over that period but it might have been precompiled again with other packages changing.

Packages in play: (@v1.5) pkg> st StatusC:\Users\jsutherland.julia\environments\v1.5\Project.toml [c52e3926] Atom v0.12.17 [336ed68f] CSV v0.7.4 [944b1d66] CodecZlib v0.7.0 [a10d1c49] DBInterface v2.2.0 [a93c6f00] DataFrames v0.21.4 [1313f7d8] DataFramesMeta v0.5.1 [864edb3b] DataStructures v0.17.19 [55939f99] DecFP v1.0.0 [31c24e10] Distributions v0.23.5 [5789e2e9] FileIO v1.4.0 [38e38edf] GLM v1.3.9 [28b8d3ca] GR v0.51.0 [c27321d9] Glob v1.3.0 [f67ccb44] HDF5 v0.13.2 [a98d9a8b] Interpolations v0.12.10 [4138dd39] JLD v0.10.0 [033835bb] JLD2 v0.1.14 [0f8b85d8] JSON3 v1.1.1 [e5e0dc1b] Juno v0.8.2 [be6f12e9] ODBC v1.0.3 [a15396b6] OnlineStats v1.5.3 [429524aa] Optim v0.22.0 [b98c9c47] Pipe v1.3.0 [91a5bcdd] Plots v1.5.5 [08abe8d2] PrettyTables v0.9.1 [92933f4c] ProgressMeter v1.3.2 [1fd47b50] QuadGK v2.4.0 [295af30f] Revise v2.7.3 [90137ffa] StaticArrays v0.12.4 [2913bbd2] StatsBase v0.33.0 [3eaba693] StatsModels v0.6.12 [f3b207a7] StatsPlots v0.14.6 [9e3dc215] TimeSeries v0.18.0 [37b6cedf] Traceur v0.3.1 [3bb67fe8] TranscodingStreams v0.9.5 [fdbf4ff8] XLSX v0.7.2 [a5390f91] ZipFile v0.9.2 [ade2ca70] Dates [37e2e46d] LinearAlgebra [56ddb016] Logging [9a3f8284] Random [10745b16] Statistics

Environment: julia> versioninfo() Julia Version 1.5.0-rc1.0 Commit 24f033c951 (2020-06-26 20:13 UTC) Platform Info: OS: Windows (x86_64-w64-mingw32) CPU: Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-9.0.1 (ORCJIT, sandybridge)

ltf-canada commented 4 years ago

Looks like this may be an environment or package version issue. It works for me on a different server.

I will continue to track down what has caused the difference.

quinnj commented 4 years ago

Sorry you're seeing an issue; there is a list of known issues here. A few things include possible bugs in the driver when it's trying to convert UTF8 characters; do you know if you have UTF8 characters in a text column? The other thing it mentioned is throwing an error if a string value is over 8000 characters.

Also, it's always helpful w/ bug reports like this to share the OS you're running things on, the version of the driver, etc.

quinnj commented 3 years ago

Closing due to inactivity; please respond if it's still an issue and you can reproduce and I'm happy to take a look and help debug.