Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oracle pl/sql:如果可能出现异常,如何放置所有行的值?_Oracle_Exception_Plsql_Exception Handling - Fatal编程技术网

Oracle pl/sql:如果可能出现异常,如何放置所有行的值?

Oracle pl/sql:如果可能出现异常,如何放置所有行的值?,oracle,exception,plsql,exception-handling,Oracle,Exception,Plsql,Exception Handling,我有一个将值从一个表传递到另一个表的过程 create table t_num(num number(10,2)); create table t_str(str varchar2(10)); insert into t_str (str) values('23'); insert into t_str (str) values('2 3'); insert into t_str (str) values('2 3,3 2'); insert into t_str (str) values('2

我有一个将值从一个表传递到另一个表的过程

create table t_num(num number(10,2));
create table t_str(str varchar2(10));
insert into t_str (str) values('23');
insert into t_str (str) values('2 3');
insert into t_str (str) values('2 3,3 2');
insert into t_str (str) values('2 3,3 223');
commit;

create or replace procedure put_to_t_num
as
    type t_num_t is table of t_num%rowtype index by binary_integer;
    tn t_num_t;
    n binary_integer := 0;
begin
    delete from t_num;
    --tn := t_num_t();
    for rec in ( select * from t_str )
    loop
        n := n + 1;
        --tn.extend;
        tn(n).num := to_number( regexp_replace( regexp_replace( rec.str, ',', '.'), ' ', '' ) );
    end loop;

    forall i in 1..n
        insert into t_num (
            num
        ) values (
            tn(i).num
        );
        --commit;
end;

tn(n).num := to_number( regexp_replace( regexp_replace( rec.str, ',', '.'), ' ', '' ) );
可能引发异常值\u错误

但我需要在代码中插入所有值,例如,如果异常,则插入0而不是实际值,这些值不会转换(类似于其他语言中的try-catch)

如何在代码中实现这一点


谢谢

而不是这一行:

tn(n).num := to_number( regexp_replace( regexp_replace( rec.str, ',', '.'), ' ', '' ) );
使用此子块处理异常:

begin 
  tn(n).num := to_number( regexp_replace( regexp_replace( rec.str, ',', '.'), ' ', '' ) );
exception when VALUE_ERROR
  then tn(n).num := 0;
end;

谢谢,但是。。。我在浏览器控制台上取得了成功,但在调用此过程后,表t_num中没有数据。是否打开了
commit
?在您的代码中,它已被注释。再次感谢您,这是nls_数字_字符的另一个问题,您的答案是我的问题的最佳答案(我之前提到的internet连接问题)可能的重复