sqlQuery:无法将ID号作为Character输入R? [英] sqlQuery: impossible to get the ID number as Character into R?

查看:53
本文介绍了sqlQuery:无法将ID号作为Character输入R?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在ORACLE DATA BASE(DB)中使用 RODBC 包。一切都做得很好,但是我需要从该数据库中获取一张表,并使用一些变量作为字符类型,而不是数字。

I'm using the RODBC package inside an ORACLE DATA BASE (DB). Everything is doing very well, but I need to obtain a table from this DB and some variables as character type, not numbers.

所以,我这样查询:

e    ManzResul_VIII<-sqlQuery(con,"select distinct t.fono_id_dis,
            t.id_predio,
            t.co_calle,
            t.nu_casa,
            t.x,
            t.y,
            t.plancheta  from c_araya.proy_dist08_todo t  where nvl(t.fono_tipo_dis, '-') not in ('CLIENTE', 'POTENCIAL', 'CARTERA')  and nvl(t.x, 0) <> 0 ")

不可能将ID号作为Character获取,此查询将iDs变量的类型从字符为数字类型(ID开头为零,但已将其更改为数字)。我已经阅读了功能说明,但可以看到如何对其进行管理。

Is impossible to get the ID number as Character, this query change the type of my iDs variables from Character to Numeric type (The ID has a zero at the beginning, but has been changed it into a number). I have read the function description, but I can see how to manage it.

任何想法都会受到赞赏,谢谢!!

Any idea would be really appreciated, thanks in advance!

推荐答案

更改查询以将ID强制转换为所需的数据类型:

Change the query to cast the id to the data type you want:

select distinct cast(t.fono_id_dis as varchar(255)) as id
. . . 

这适用于大多数数据库。

This should work with most databases.

这篇关于sqlQuery:无法将ID号作为Character输入R?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆