Main Tables Views Indexes Constraints Triggers Procedures Functions Packages Sanity check Index

ACS3 Data Model

Arguments Source

APM_VERSION_ORDER

Arguments:

NameData TypeDefault ValueIn/Out
V_VERSION_NAMEVARCHAR2 IN

Returns:

VARCHAR2

Source

Source
     1: function apm_version_order(v_version_name in varchar) return varchar is
     2:     a_start integer;
     3:     a_end   integer;
     4:     a_order varchar(1000);
     5:     a_char  char(1);
     6:     a_seen_letter char(1) := 'f';
     7: begin
     8:     a_start := 1;
     9:     loop
    10:         a_end := a_start;
    11: 
    12:         -- keep incrementing a_end until we run into a non-number
    13:         while substr(v_version_name, a_end, 1) >= '0' and substr(v_version_name, a_end, 1) <= '9' loop
    14:             a_end := a_end + 1;
    15:         end loop;
    16:         if a_end = a_start then
    17:             raise_application_error(-20000, 'Expected number at position ' || a_start);
    18:         end if;
    19:         if a_end - a_start > 4 then
    20:             raise_application_error(-20000, 'Numbers within versions can only be up to 4 digits long');
    21:         end if;
    22: 
    23:         -- zero-pad and append the number
    24:         a_order := a_order || substr('0000', 1, 4 - (a_end - a_start)) ||
    25:             substr(v_version_name, a_start, a_end - a_start) || '.';
    26:         if a_end > length(v_version_name) then
    27:             -- end of string - we're outta here
    28:             if a_seen_letter = 'f' then
    29:                 -- append the "final" suffix if there haven't been any letters
    30:                 -- so far (i.e., not development/alpha/beta)
    31:                 a_order := a_order || '  3F.';
    32:             end if;
    33:             return a_order;
    34:         end if;
    35: 
    36:         -- what's the next character? if a period, just skip it
    37:         a_char := substr(v_version_name, a_end, 1);
    38:         if a_char = '.' then
    39:             null;
    40:         else
    41:             -- if the next character was a letter, append the appropriate characters
    42:             if a_char = 'd' then
    43:                 a_order := a_order || '  0D.';
    44:             elsif a_char = 'a' then
    45:                 a_order := a_order || '  1A.';
    46:             elsif a_char = 'b' then
    47:                 a_order := a_order || '  2B.';
    48:             else
    49:                 -- uhoh... some wacky character. bomb
    50:                 raise_application_error(-20000, 'Illegal character ''' || a_char ||
    51:                     ' in version name ' || v_version_name || '''');
    52:             end if;
    53: 
    54:             -- can't have something like 3.3a1b2 - just one letter allowed!
    55:             if a_seen_letter = 't' then
    56:                 raise_application_error(-20000, 'Not allowed to have two letters in version name '''
    57:                     || v_version_name || '''');
    58:             end if;
    59:             a_seen_letter := 't';
    60: 
    61:             -- end of string - we're done!
    62:             if a_end = length(v_version_name) then
    63:                 return a_order;
    64:             end if;
    65:         end if;
    66:         a_start := a_end + 1;
    67:     end loop;
    68: end;


Generated by OraSchemaDoc, (c) Aram Kananov, 2002