ISSUE
Cannot insert NA values from a data.frame to a DB Table
STEPS
Read table from SQL server into R
data.frame
. Table is decimal with someNULL
. data.frame is numeric with someNA
.dBWriteTable
throws the following errorError in .local(conn, statement, ...) : execute JDBC update query failed in dbSendUpdate (The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 57 (""): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision.)
I overwrite NA with 0s like
dataset$column[is.na(dataset$column)] = 0
dBWriteTable
successfully writes onto DB
R Details
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server 7.5 (Maipo)
RJDBC_0.2-7.1 rJava_0.9-10 DBI_1.0.0