davidzxc574
davidzxc574

Reputation: 491

varchar2 in Oracle becomes num in R

I have a table tbl_Rum in Oracle database and it has a column AAB varchar2(12). A value from AAB is 004410001600'. But after I imported into R via ODBC with the following code, this AAB became a num column and the two leading zeroes disappeared. Is there a way of avoiding this column transformation?

Thanks

conODBC<-odbcConnect(dsn="xxxxx", uid="xxxx", pwd="xxxx", readOnly=FALSE)
tbl_Rum<-sqlQuery(conODBC, "select * from tbl_Rum", rows_at_time=1)
str(tbl_Rum)


'data.frame':   3 obs. of  2 variables:

$ AAA: Factor w/ 2 levels "H31000000000000",..: 1 1 2

$ AAB: num  4.41e+09 7.39e+09 1.89e+10

Upvotes: 0

Views: 67

Answers (1)

davidzxc574
davidzxc574

Reputation: 491

yes, sqlQuery(channel,"select ...",as.is=TRUE) works!

Upvotes: 1

Related Questions