专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Oracle Exception

update错误

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草

update错误:

我建立了一个表x有A,B两个字段,都是Number数据类型,字段C为Varchar2数据类型
我用一条SQL语句执行UPDATE,C的字段是A,B两个值连接,却报错,提示无效数字
例如A为0.6,B为710,我想让C变为0.6*710,语句如下:
update  x  set  c=to_char(a) +  '*'+  to_char(b)
请问错在哪里了,正确的改如何写?

------解决方法--------------------------------------------------------
字符连接用“||”
update  x  set  c=to_char(a)||'*'||to_char(b)
------解决方法--------------------------------------------------------
改为

SQL code
update  x  set  c=to_char(a) ||  '*' ||  to_char(b)


------解决方法--------------------------------------------------------
update  x  set  c=to_char(a) ||  '*'||  to_char(b)
------解决方法--------------------------------------------------------
[code=SQL]
SQL> select to_char(0.6,'fm99990.9999999') from dual;

TO_CHAR(0.6,'F
--------------
0.6

已选择 1 行。

SQL>

code]
------解决方法--------------------------------------------------------
SQL code
SQL> select rtrim(to_char(0.6,'fm999999999990.9999'),'.') from dual;

RTRIM(TO_CHAR(0.6,'FM999999999

------------------------------

0.6

SQL> select rtrim(to_char(710,'fm999999999990.9999'),'.') from dual;

RTRIM(TO_CHAR(710,'FM999999999

------------------------------

710


------解决方法--------------------------------------------------------
oracle 连接不是'+',而是'||'
select to_char(0.6,'fm99990.9999999')||'*'||10 from dual;

    
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: