JuliaDatabases / ODBC.jl

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

Query now too long? #259

Closed JockLawrie closed 4 years ago

JockLawrie commented 4 years ago

Hi there,

I am extracting data from a SQL Server instance. I'm running Julia 1.4.0 on Windows 10 with ODBC.jl v0.8.1. The error is below. I have been running this query without issue on another machine, which I no longer have access to. Other than breaking the query up into pieces, is there something else I can do?

[ODBC] 42000: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]The identifier that starts with 'select EventId, HospitalAdmission, HospitalEmergency, OnsetMinutes as TimeToOnset, SymptomsPersistedMinutes as SymptomDuration,
' is too long. Maximum length is 128.
ERROR: ODBC.ODBCError("API.SQLExecDirect(stmt, query) failed; return code: -1 => SQL_ERROR")
Stacktrace:
 [1] macro expansion at C:\Users\Owner\.julia\packages\ODBC\KFiOK\src\ODBC.jl:57 [inlined]
 [2] ODBC.Query(::ODBC.DSN, ::String) at C:\Users\Owner\.julia\packages\ODBC\KFiOK\src\Query.jl:47
 [3] query(::ODBC.DSN, ::String, ::Type{DataFrames.DataFrame}; weakrefstrings::Bool, append::Bool, transforms::Dict{Int64,Function}) at C:\Users\Owner\.julia\packages\ODBC\KFiOK\src\Query.jl:278
 [4] query at C:\Users\Owner\.julia\packages\ODBC\KFiOK\src\Query.jl:273 [inlined]
 [5] query at C:\Users\Owner\.julia\packages\ODBC\KFiOK\src\Query.jl:264 [inlined]
 [6] fetch_data(::Saefvic.config.SafeVacConfig) at C:\Data\ScheduledTasks\SAEFVIC_ETL\Saefvic.jl\src\fetchdata.jl:19
 [7] main(::String) at C:\Data\ScheduledTasks\SAEFVIC_ETL\Saefvic.jl\src\run.jl:23
 [8] top-level scope at REPL[7]:1
quinnj commented 4 years ago

Hmmmm, something funny is going on. identifier in SQL is usually a single entity name: column, table, database, etc. So the fact that it's saying the select EventId... is all one identifier makes me wonder if you have double quotes around that whole string? Maybe there's some inadvertent quote interpolation going on? Can you double check your query to make sure you don't have misplaced double quotes?

quinnj commented 4 years ago

Please comment/reopen if it's still an issue.