I am a Julia beginner and do not know how to convert column type Union{Missing, Dec64} to Integer in the output from ODBC. I am using Julia 1.4.2 and ODBC 1.0.0 on Windows 10 with an Oracle database driver.
The result of DBInterface.execute(conn, sql) on my SQL query is ODBC.Cursor{false,false} which at the end includes "metadata" with a 3x7 Array{Any,2} with two columns for ZIPCODE_ZIP and ZIPCODE_COUNTY of column type Union{Missing, Dec64}.
Ideally, I would like to avoid the conversion and if possible simply extract the two Dec64 type columns as Integer.
MethodError: Cannot `convert` an object of type Array{Union{Missing, DecFP.Dec64},1} to an object of type Int32
Closest candidates are:
convert(::Type{Int32}, !Matched::DecFP.Dec32) at C:\Users\aalexandersson\.julia\packages\DecFP\quvcm\src\DecFP.jl:454
convert(::Type{Int32}, !Matched::DecFP.Dec64) at C:\Users\aalexandersson\.julia\packages\DecFP\quvcm\src\DecFP.jl:454
convert(::Type{Int32}, !Matched::DecFP.Dec128) at C:\Users\aalexandersson\.julia\packages\DecFP\quvcm\src\DecFP.jl:454
Having a documented example of how to convert the data type or to get the wanted data type directly would be very helpful to me as a beginner for using ODBC.
Edit: I think display formatting is what I want, rather than conversion. This is the easiest solution I found to get rid of the decimals:
using PrettyTables
pretty_table(x, formatters = ft_printf("%.0f"))
I am a Julia beginner and do not know how to convert column type
Union{Missing, Dec64}
to Integer in the output from ODBC. I am using Julia 1.4.2 and ODBC 1.0.0 on Windows 10 with an Oracle database driver.The result of
DBInterface.execute(conn, sql)
on my SQL query isODBC.Cursor{false,false}
which at the end includes "metadata" with a3x7 Array{Any,2}
with two columns for ZIPCODE_ZIP and ZIPCODE_COUNTY of column typeUnion{Missing, Dec64}
.Ideally, I would like to avoid the conversion and if possible simply extract the two
Dec64
type columns as Integer.I tried
convert(Int32, get(x.ZIPCODE_ZIP))
(based on https://discourse.julialang.org/t/decfp-type-conversion-to-integer/5752 and https://docs.julialang.org/en/v1/manual/integers-and-floating-point-numbers/) but get errorHaving a documented example of how to convert the data type or to get the wanted data type directly would be very helpful to me as a beginner for using ODBC.
Edit: I think display formatting is what I want, rather than conversion. This is the easiest solution I found to get rid of the decimals: