Skip to content

Latest commit

 

History

History
112 lines (73 loc) · 2.5 KB

oos_util.md

File metadata and controls

112 lines (73 loc) · 2.5 KB

OOS_UTIL

Constants

Name Code Description
gc_date_format gc_date_format constant varchar2(255) := 'DD-MON-YYYY HH24:MI:SS'; default date format
gc_timestamp_format `gc_timestamp_format constant varchar2(255) := gc_date_format
gc_timestamp_tz_format `gc_timestamp_tz_format constant varchar2(255) := gc_timestamp_format
gc_version gc_version constant varchar2(10) := '1.0.0';

ASSERT Procedure

Validates assertion.
Will raise an application error if assertion is false

Syntax

procedure assert(
  p_condition in boolean,
  p_msg in varchar2)

Parameters

Name Description
p_condition Boolean condition to validate
p_msg Message to include in application error if p_condition fails

Example


oos_util.assert(1=2, 'this assertion did not pass');

-- Results in

Error starting at line : 1 in command -
exec oos_util.assert(1=2, 'this assertion did not pass')
Error report -
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'ASSERT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

SLEEP Procedure

Sleep procedure for n seconds

Notes:

  • It is recommended that you use Oracle's lock procedures: http://psoug.org/reference/sleep.html
    • In instances where you do not have access use this sleep method instead
  • This implementation may tie up CPU so only use for development purposes
  • This is a custom implementation of sleep and as a result the times are not 100% accurate
  • If calling in SQLDeveloper may get "IO Error: Socket read timed out". This is a JDBC driver setting, not a bug in this code.

Syntax

procedure sleep(
  p_seconds in simple_integer)

Parameters

Name Description
p_seconds Number of seconds to sleep for

Example

begin
  dbms_output.put_line(oos_util_string.to_char(sysdate));
  oos_util.sleep(5);
  dbms_output.put_line(oos_util_string.to_char(sysdate));
end;
/

26-APR-2016 14:29:02
26-APR-2016 14:29:07