create or replace PACKAGE PS_Parse IS /* || PL/SQL table structures to hold atomics retrieved by parse_string. || This includes the table type definition, a table (though you can || declare your own as well, and an empty table, which you can use || to clear out your table which contains atomics. */ TYPE atoms_tabtype IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER; atoms_table atoms_tabtype; empty_atoms_table atoms_tabtype; /* || The standard list of delimiters. You can over-ride these with || your own list when you call the procedures and functions below. || This list is a pretty standard set of delimiters, though. */ std_delimiters VARCHAR2 (50) := ' !@#$%^&*()-_=+\|`~{{]};:''",<.>/?'; /* Display contents of table using DBMS_OUTPUT */ PROCEDURE display_atomics (table_in IN atoms_tabtype, num_rows_in IN NUMBER); /* || The parse_string procedure: I provide two, overloaded definitions. || The first version puts all atomics into a PL/SQL table and would || be used in a PL/SQL Version 2 environment. The second version places || all atomics into a string, separating each atomic by a vertical bar. || (My code does NOT do any special handling when it finds a "|" in || the string. You have to deal with that when you extract the atomics. || || See the program definition for more details on other parameters. */ PROCEDURE parse_string (string_in IN VARCHAR2, atomics_list_out OUT atoms_tabtype, num_atomics_out IN OUT NUMBER, delimiters_in IN VARCHAR2 := std_delimiters); PROCEDURE parse_string (string_in IN VARCHAR2, atomics_list_out IN OUT VARCHAR2, num_atomics_out IN OUT NUMBER, delimiters_in IN VARCHAR2 := std_delimiters); /* Count the number of atomics in a string */ FUNCTION number_of_atomics (string_in IN VARCHAR2, count_type_in IN VARCHAR2 := 'ALL', delimiters_in IN VARCHAR2 := std_delimiters) RETURN INTEGER; /* Return the Nth atomic in the string */ FUNCTION nth_atomic (string_in IN VARCHAR2, nth_in IN NUMBER, count_type_in IN VARCHAR2 := 'ALL', delimiters_in IN VARCHAR2 := std_delimiters) RETURN VARCHAR2; END PS_Parse; /