RODBC string getting truncated
Posted
by
sayan dasgupta
on Stack Overflow
See other posts from Stack Overflow
or by sayan dasgupta
Published on 2011-01-07T07:36:53Z
Indexed on
2011/01/07
8:53 UTC
Read the original article
Hit count: 223
Hi all,
I am fetching data from MySql Server into R using RODBC.
So in one column of the database is a character vector
SELECT MAX(CHAR_LENGTH(column)) FROM reqtable;
RETURNS 26566
Now I will show you an example how I am running into the problem
`library(RODBC)
con <- odbcConnect("mysqlcon")
rslts <- as.numeric(sqlQuery(con,
"SELECT CHAR_LENGTH(column) FROM reqtable LIMIT 10",
as.is=TRUE)[,1])
` returns
> rslts
[1] 62 31 17 103 30 741 28 73 25 357
where as
rslts <- nchar(as.character(sqlQuery(con,
"SELECT column FROM reqtable LIMIT 10",
as.is=TRUE)[,1]))
returns
> rslts
[1] 62 31 17 103 30 255 28 73 25 255
So strings with length > 255 is getting truncated at 255. Is there a way I can get the full string.
Thanks
© Stack Overflow or respective owner