Merge branch 'master' of github.com:mortenbra/alexandria-plsql-utils

This commit is contained in:
Morten Braten 2015-07-20 21:53:38 +02:00
commit 2b6d76bb81
4 changed files with 80 additions and 4 deletions

View File

@ -75,7 +75,7 @@ This library is a collection of various utility packages for PL/SQL, as well as
##Parse JSON using PL/SQL
* http://sourceforge.net/projects/pljson/
* https://github.com/pljson/pljson
* http://reseau.erasme.org/pl-sql-library-for-JSON?lang=en

View File

@ -401,7 +401,7 @@ begin
if l_type = 's' then
l_string_index := to_number (l_returnvalue);
l_xml := get_xml (p_xlsx, 'xl/sharedStrings.xml');
l_returnvalue := xml_util_pkg.extract_value (l_xml, '/sst/si[' || (l_string_index + 1) || ']/t/text()', g_namespace_xlsx_sharedstrings);
l_returnvalue := xml_util_pkg.extract_value (l_xml, '/sst/si[' || (l_string_index + 1) || ']//t/text()', g_namespace_xlsx_sharedstrings);
end if;
return l_returnvalue;
@ -453,7 +453,7 @@ begin
if l_type = 's' then
l_string_index := to_number (l_returnvalue(i));
l_returnvalue(i) := xml_util_pkg.extract_value (l_shared_strings, '/sst/si[' || (l_string_index + 1) || ']/t/text()', g_namespace_xlsx_sharedstrings);
l_returnvalue(i) := xml_util_pkg.extract_value (l_shared_strings, '/sst/si[' || (l_string_index + 1) || ']//t/text()', g_namespace_xlsx_sharedstrings);
end if;
end loop;

View File

@ -487,6 +487,50 @@ begin
end remove_non_alpha_chars;
function is_str_alpha (p_str in varchar2) return boolean
as
l_returnvalue boolean;
begin
/*
Purpose: returns true if string only contains alpha characters
Who Date Description
------ ---------- -------------------------------------
MJH 12.05.2015 Created
*/
l_returnvalue := regexp_instr(p_str, '[^a-z|A-Z]') = 0;
return l_returnvalue;
end is_str_alpha;
function is_str_alphanumeric (p_str in varchar2) return boolean
as
l_returnvalue boolean;
begin
/*
Purpose: returns true if string is alphanumeric
Who Date Description
------ ---------- -------------------------------------
MJH 12.05.2015 Created
*/
l_returnvalue := regexp_instr(p_str, '[^a-z|A-Z|0-9]') = 0;
return l_returnvalue;
end is_str_alphanumeric;
function is_str_empty (p_str in varchar2) return boolean
as
l_returnvalue boolean;
@ -557,6 +601,28 @@ begin
end is_str_number;
function is_str_integer (p_str in varchar2) return boolean
as
l_returnvalue boolean;
begin
/*
Purpose: returns true if string is an integer
Who Date Description
------ ---------- -------------------------------------
MJH 12.05.2015 Created
*/
l_returnvalue := regexp_instr(p_str, '[^0-9]') = 0;
return l_returnvalue;
end is_str_integer;
function short_str (p_str in varchar2,
p_length in number,
p_truncation_indicator in varchar2 := '...') return varchar2
@ -694,10 +760,11 @@ begin
Who Date Description
------ ---------- -------------------------------------
MBR 06.01.2009 Created
MJH 12.05.2015 Leverage string_util_pkg.str_to_bool in order to reduce code redundancy
*/
if lower(p_str) in ('y', 'yes', 'true', '1') then
if str_to_bool(p_str) then
l_returnvalue := g_yes;
end if;

View File

@ -92,6 +92,12 @@ as
-- remove all non-alpha characters (A-Z) from string
function remove_non_alpha_chars (p_str in varchar2) return varchar2;
-- returns true if string only contains alpha characters
function is_str_alpha (p_str in varchar2) return boolean;
-- returns true if string is alphanumeric
function is_str_alphanumeric (p_str in varchar2) return boolean;
-- returns true if string is "empty" (contains only whitespace characters)
function is_str_empty (p_str in varchar2) return boolean;
@ -100,6 +106,9 @@ as
p_decimal_separator in varchar2 := null,
p_thousand_separator in varchar2 := null) return boolean;
-- returns true if string is an integer
function is_str_integer (p_str in varchar2) return boolean;
-- returns substring and indicates if string has been truncated
function short_str (p_str in varchar2,
p_length in number,