Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
REM **************************************************************
REM David L. Hunt (file author) distributes this and other
REM files/scripts for educational purposes only, to illustrate the
REM use or application of various computing techniques. Neither the
REM author nor "Dasages, LLC" makes any warranty regarding this
REM script's fitness for any industrial application or purpose nor is
REM there any claim that this or any similarly-distributed scripts
REM are error free or should be used for any purpose other than
REM illustration.
REM
REM Please contact the author via email (dave@dasages.com) when
REM you have comments, suggestions, and/or difficulties with this
REM package or its functions.
REM
REM [Please keep the above disclaimer and the embedded electronic
REM documentation with this script.]
REM **************************************************************
REM About this script/file:
REM
REM This is a generalized package to produce two persistent
REM variables each for dates, numbers, and varchar variables.
REM The package also creates functions to return the values stored
REM in the persistent variables.
REM
REM **************************************************************
create or replace package dh_ws is
ws_date1 date;
ws_date2 date;
WS_NUMBER1 number;
WS_NUMBER2 number;
ws_varchar1 varchar(2000);
ws_varchar2 varchar(2000);
function get_n (x in varchar2) return number;
function get_d (x in varchar2) return date;
function get_x (x in varchar2) return varchar2;
pragma restrict_references(get_n,WNDS);
pragma restrict_references(get_d,WNDS);
pragma restrict_references(get_x,WNDS);
end;
/
create or replace package body dh_ws is
function get_n (x in varchar2) return number is
begin
if upper(x) = 'WS_NUMBER1' then
return WS_NUMBER1;
end if;
if upper(x) = 'WS_NUMBER2' then
return WS_NUMBER2;
end if;
end get_n;
function get_d (x in varchar2) return date is
begin
if upper(x) = 'WS_DATE1' then
return ws_DATE1;
end if;
if upper(x) = 'WS_DATE2' then
return ws_DATE2;
end if;
end get_d;
function get_x (x in varchar2) return varchar2 is
begin
if upper(x) = 'WS_VARCHAR1' then
return ws_VARCHAR1;
end if;
if upper(x) = 'WS_VARCHAR2' then
return ws_VARCHAR2;
end if;
end get_x;
end;
/
SQL> exec dh_ws.ws_number1 := 50
PL/SQL procedure successfully completed.
SQL> exec dh_ws.ws_number2 := 5
PL/SQL procedure successfully completed.
SQL> exec dh_ws.ws_number1 := dh_ws.ws_number1 + dh_ws.ws_number2
PL/SQL procedure successfully completed.
SQL> set serveroutput on
SQL> exec dbms_output.put_line(dh_ws.ws_number1);
55
PL/SQL procedure successfully completed.
SQL> select dh_ws.get_n('ws_number1') from dual;
DH_WS.GET_N('WS_NUMBER1')
-------------------------
55