Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ORA-06502: PL/SQL: character to number conversion error while using variable

I know its been asked a lot but didn’t know how to apply it in a variable;

this is my code

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;
/

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It is much simpler:

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;
/
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading