Monday, October 5, 2015

Oracle Wrapping

it is example of wrapping oracle pl/sql

CREATE OR REPLACE FUNCTION GET_1 RETURN NUMBER IS
BEGIN
  RETURN 1;
END;
/

Test it:
SELECT get_1 FROM dual;

Check dba_source:
SELECT LINE, TEXT FROM DBA_SOURCE WHERE NAME = 'GET_1' ORDER BY LINE;

      LINE TEXT
---------- ----------------------------------
         1 FUNCTION GET_1 RETURN NUMBER IS
         2 BEGIN
         3   RETURN 1;
         4 END;

Get wrapped source
select SYS.DBMS_DDL.wrap( '
create or replace function get_1 return number
is
begin
  return 1' || chr(59)||'
end' || chr(59)||'
' ) wrapped_source from DUAL;

WRAPPED_SOURCE
--------------------------------------------------------------------------------

create or replace function get_1 wrapped
a000000
27
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
38 69
xzk0ly8PFjTNqoXGivso2L4+wvYwg8eZgcfLCNL+XlquYvR4w+fAsr2ym16lmYEywLIGm3SL
wMAy/tKGCamhBKPHvpK+VMd/pqa+9ct/

Compile wrapped source in the database:
BEGIN
  SYS.DBMS_DDL.create_wrapped( '
create or replace function get_1 return number
is
begin
  return 1' || chr(59)||'
end' || chr(59)||'
' );
END;
/

Check dba_source again:
SELECT LINE, TEXT FROM DBA_SOURCE WHERE NAME = 'GET_1' ORDER BY LINE;
      LINE TEXT
---------- --------------------------------------------------------------------------------
         1 function get_1 wrapped
           a000000
           27
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           abcd
           8
           38 69
           xzk0ly8PFjTNqoXGivso2L4+wvYwg8eZgcfLCNL+XlquYvR4w+fAsr2ym16lmYEywLIGm3SL
           wMAy/tKGCamhBKPHvpK+VMd/pqa+9ct/

No comments:

Post a Comment