Thursday, August 2, 2012

Using DBMS_RCVMAN to display human readable byte sizes and time

The DBMS_RCVMAN.num2displaysize procedure can be used to display human readable byte sizes. The DBMS_RCVMAN.Sec2DisplayTime procedure can display a time format given seconds. The drawback is the DBMS_RCVMAN package is only available to SYS.

SQL> select sys.dbms_rcvman.num2displaysize(1024) sz from dual;

SZ
-------------------------------------------------------------------------------
    1.00K

SQL> select sys.dbms_rcvman.num2displaysize(235236346) sz from dual;

SZ
-------------------------------------------------------------------------------
  224.34M

SQL> select sys.dbms_rcvman.num2displaysize(1024*1024*1024*1024) sz from dual;

SZ
-------------------------------------------------------------------------------
    1.00T

Given a number of seconds display in time format:

SQL> select dbms_rcvman.Sec2DisplayTime(600) dt from dual;

DT
------------------------------
00:10:00

SQL> select dbms_rcvman.Sec2DisplayTime(90035) dt from dual;

DT
------------------------------
25:00:35

SQL>

No comments:

Post a Comment