rem {{ $Header: L:\\\\model\\jin\\RCS\\jricmnt.jpb 40.2 1998/05/27 13:08:01 eharding Exp $ rem {{ -----------------------------------------------------------------------+ rem File: $Workfile: jrpbcmnt.sql $ rem Author: $Author: eharding $ rem Date: $Date: 1998/05/27 13:08:01 $ rem Version: $Revision: 40.2 $ rem Status: $State: Exp $ rem Locked_by: $Locker: $ rem Project: The Oracle Repository rem Description: Comment utilities package body rem Notes: rem RealAuth: Jay Gitterman rem IncepDate: 19 December 1997 rem Copyright: (c) Oracle Corporation 1997. All Rights Reserved. rem Tagline: -- Oracle Repository: Managing *all* your data -- rem --------------------------------------------------------------------------+ rem Log of Changes from Source Control System rem --------------------------------------------------------------------------+ rem $Log: jricmnt.jpb $ rem Revision 40.2 1998/05/27 13:08:01 eharding rem Moved reference JR_* PL/SQL from ClearCase rem rem rem Rev 1.6 14 Jan 1998 18:06:04 kmchorto rem Restructuring: Checkpoint for Jon & DavidD rem rem Rev 1.5 12 Jan 1998 20:34:44 kmchorto rem Checkpoint for Schema Cutover rem rem Rev 1.4 23 Dec 1997 14:14:38 jgitterm rem remove spaces from returned comment rem rem Rev 1.4 23 Dec 1997 13:11:22 jgitterm rem remove spaces from returned comment rem rem Rev 1.3 19 Dec 1997 11:21:16 jgitterm rem test for null list in lookup rem rem Rev 1.2 19 Dec 1997 11:03:10 jgitterm rem add lookup() rem rem Rev 1.1 19 Dec 1997 10:47:08 jgitterm rem rem Rev 1.0 19 Dec 1997 10:26:26 jgitterm rem Initial revision. rem }} -----------------------------------------------------------------------+ prompt Package Body: jr_comment create or replace package body jr_comment is REPOS_PRAGMA constant varchar2(13) := '#REPOS_PRAGMA'; function get_keywords (a_comment in out varchar2) return tvp_list is token_list_string all_tab_comments.comments%type; the_tvp tvp; the_list tvp_list; idx pls_integer := 0; start_ptr pls_integer := 0; end_ptr pls_integer := 0; before_chunk all_tab_comments.comments%type; after_chunk all_tab_comments.comments%type; procedure next_tvp is tok varchar2(100); sep pls_integer; procedure next_token is i pls_integer := 0; begin i := instr(token_list_string, ','); if (i > 0) then tok := ltrim(rtrim(substr(token_list_string, 1, i-1))); if (tok is null) then raise invalid_comment; end if; token_list_string := ltrim(substr(token_list_string, i+1)); elsif (i = 1) then raise invalid_comment; else tok := ltrim(rtrim(token_list_string)); token_list_string := null; end if; end next_token; begin next_token; if tok is not null then sep := instr(tok, '='); if (sep > 1) then the_tvp.tag := rtrim(substr(tok, 1, sep-1)); the_tvp.value := ltrim(substr(tok, sep+1)); if (instr(the_tvp.value, '=') > 0) then raise invalid_comment; end if; elsif (sep = 1) then raise invalid_comment; else the_tvp.tag := tok; the_tvp.value := null; end if; else the_tvp := null; end if; end next_tvp; begin start_ptr := instr(upper(a_comment), REPOS_PRAGMA); if (start_ptr > 0) then before_chunk := substr(a_comment, 1, start_ptr-1); token_list_string := ltrim(substr(a_comment, start_ptr+length(REPOS_PRAGMA))); start_ptr := instr(token_list_string, '{'); if (start_ptr != 1) then raise invalid_comment; end if; end_ptr := instr(token_list_string, '}', 2); if (end_ptr < 2) then raise invalid_comment; end if; after_chunk := substr(token_list_string, end_ptr+1); token_list_string := rtrim(substr(token_list_string, start_ptr+1, end_ptr-start_ptr-1)); if (instr(token_list_string, ',', -1) = length(token_list_string)) then -- list ends with a separator raise invalid_comment; end if; next_tvp; if the_tvp.tag is not null then the_list := tvp_list(); loop idx := idx + 1; the_list.extend; the_list(idx) := the_tvp; next_tvp; exit when the_tvp.tag is null; end loop; end if; a_comment := rtrim(before_chunk)||after_chunk; end if; return the_list; exception when invalid_comment then raise_application_error(-20000, 'Invalid comment string'); end get_keywords; function lookup (a_list in tvp_list, keyword in varchar2, value out varchar2) return boolean is begin if a_list is not null then for i in 1..a_list.count loop if (upper(a_list(i).tag) = upper(keyword)) then value := a_list(i).value; return TRUE; end if; end loop; end if; return FALSE; end lookup; end jr_comment; / rem rem ---------------------------------------------------------------------------+ rem }} End of file $Workfile: jrpbcmnt.sql $ $$Header_is_done rem --------------------------------------------------------------------------+