^_^>>select * from test;        ID K      VALUE
---------- - ----------
         1 a     102930^_^>>truncate table test;
表已截掉。
^_^>>desc test1;
 名称                                                  空?      类型
 ----------------------------------------------------- -------- ------------------------------------
 ID                                                             NUMBER(4)
 KIND                                                           CHAR(1)
 VALUE                                                          VARCHAR2(10)^_^>>select * from test1;        ID K VALUE
---------- - ----------
         1 a 102930^_^>>update test1 set value='12345';已更新 1 行。^_^>>select * from test1;        ID K VALUE
---------- - ----------
         1 a 12345^_^>>alter table test modify(value number(5));
表已更改。
^_^>>insert into test(id,kind,value) select id,kind,to_number(value) from test1;已创建 1 行。^_^>>select * from test;        ID K      VALUE
---------- - ----------
         1 a      12345

解决方案 »

  1.   

    select max(codeno),min(codeno) from a;看看有没有非法字符
      

  2.   

    to  maohaisheng(www.chinaspirit.net) :
    像你这样能判断出 由非法字符吗?我用你的语法,得到的结果是99,1
    但我的库里面确实有非法字符。有什么好的办法判断非法字符?我用的办法是
    select to_number(codeno) from B,在 第 960 行出错,出现非法字符。还有什么更好的办法判断是否有非法字符?
      

  3.   

    select codeno-1 from b;也可以,做法类以,也要进行全表搜索.
      

  4.   

    select codeno-1 from b 这样就是说 pl/sql也是弱类型的语言,就是将 varchar2 类型自动转换为 number 然后 -1,当不能转换的地方就出错,是吗?就像 JS 中 ,也是弱类型语言,当字符和数字相加时,自动将数字转换为字符。不知道我的理解是否正确。望高人指教
      

  5.   

    给你以下一个例子:
    SQL> set serveroutput on
    SQL> declare
      2  a varchar2(10):='111';
      3  b number:=111;
      4  begin
      5  a:=b;
      6  dbms_output.put_line('隐式转换');
      7  exception
      8  when others then
      9  dbms_output.put_line('出错');
     10  end;
     11  /
    隐式转换PL/SQL procedure successfully completed