oracle ORA-06502:PL/SQL:使用变量时字符到数字的转换错误

doinxwow  于 2023-03-17  发布在  Oracle
关注(0)|答案(1)|浏览(226)

我知道这是问了很多,但不知道如何应用它在一个变量;
这是我的密码

DECLARE

Main_time_elap varchar2(1000);
time_elap  varchar2(1000);
time_elape number(5);

BEGIN

            main_time_elap:=to_char(systimestamp,'HH24:MI:SS');

            time_elap:=to_char(systimestamp,'HH24:MI:SS');
            time_elape:=to_number(time_elap)-to_number(main_time_elap);
            --time_elape :=time_elap-main_time_elap ;

end;
/
tf7tbtn2

tf7tbtn21#

这要简单得多:

DECLARE

Main_time_elap TIMESTAMP;
time_elap  TIMESTAMP;
time_elape INTERVAL DAY TO SECOND;
sec_elape NUMBER;

BEGIN
       main_time_elap := systimestamp;

       time_elap := systimestamp;
       time_elape := time_elap - main_time_elap;    
       sec_elape := EXTRACT(SECOND FROM time_elape);
end;
/

相关问题