首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > PowerDesigner >

update异常

2012-12-26 
update错误点击右边红色标题查看本文完整版:update错误update错误:我建立了一个表x有A,B两个字段,都是Numb

update错误
点击右边红色标题查看本文完整版:update错误

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
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->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
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->SQL> select rtrim(to_char(0.6,'fm999999999990.9999'),'.') from dual;RTRIM(TO_CHAR(0.6,'FM999999999------------------------------0.6SQL> 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;
    

热点排行