Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid precision value when inserting large data into VARBINARY(max) on SQL Server #356

Open
arinrb opened this issue Dec 26, 2022 · 1 comment

Comments

@arinrb
Copy link

arinrb commented Dec 26, 2022

I am getting an "Invalid precision value" error when inserting large (larger than 8000 bytes) blobs into VARBINARY(max) columns in SQL Server using ODBC. I am using ODBC Driver 17 for SQL Server, which support this. The datatype I am binding for the inserts are of type Vector{UInt8}.

Error print
julia> DBInterface.execute(stmt, [compressed[1:8001]])
ERROR: HY104: [Microsoft][ODBC Driver 17 for SQL Server]Invalid precision value
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] bindparam(stmt::ODBC.API.Handle, x::Int64, iotype::Int16, ctype::Int16, sqltype::Int16, column_size::Int64, decimal_digits::Int64, param_value::Ptr{UInt8}, param_size::Int64, len::Ptr{Int64})
@ ODBC.API #######.julia\packages\ODBC\9VZTC\src\API.jl:111
[3] bindparam(stmt::ODBC.API.Handle, i::Int64, b::ODBC.Binding)
@ ODBC #######.julia\packages\ODBC\9VZTC\src\utils.jl:286
[4] update!(stmt::ODBC.API.Handle, b::ODBC.Binding, x::Any, i::Int64)
@ ODBC #######.julia\packages\ODBC\9VZTC\src\utils.jl:281
[5] bindparams
@ #######.julia\packages\ODBC\9VZTC\src\utils.jl:295 [inlined]
[6] execute(stmt::ODBC.Statement, params::Vector{Vector{UInt8}}; debug::Bool, kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ODBC #######.julia\packages\ODBC\9VZTC\src\dbinterface.jl:169
[7] execute(stmt::ODBC.Statement, params::Vector{Vector{UInt8}})
@ ODBC #######.julia\packages\ODBC\9VZTC\src\dbinterface.jl:164
[8] top-level scope
@ REPL[175]:1

@sdobber
Copy link

sdobber commented Mar 7, 2023

The following hack allowed me to insert larger blobs, but I guess it is bad practice to highjack Odbc.jl's code this way...

After using ODBC, write

ODBC.bindtypes(x::Vector{UInt8}) = ODBC.API.SQL_C_BINARY, ODBC.API.SQL_LONGVARBINARY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants