Does PL / SQL have an equivalent StringTokenizer for Java?

I am using java.util.StringTokenizer to easily parse delimited strings in java. I need a mechanism of the same type in pl / sql. I could write this, but if it already exists, I would prefer to use it. Does anyone know about pl / sql implementation? Useful alternative?

+4
source share
4 answers

PL / SQL includes the base for comma-separated lists ( DBMS_UTILITY.COMMA_TO_TABLE ).

Example:

 DECLARE lv_tab_length BINARY_INTEGER; lt_array DBMS_UTILITY.lname_array; BEGIN DBMS_UTILITY.COMMA_TO_TABLE( list => 'one,two,three,four' , tablen => lv_tab_length , tab => lt_array ); DBMS_OUTPUT.PUT_LINE( 'lv_tab_length = ['||lv_tab_length||']' ); FOR i IN 1..lv_tab_length LOOP DBMS_OUTPUT.PUT_LINE( '['||lt_array( i )||']' ); END LOOP; END; / 

Or check out the Ask Tom link for other ideas ...

Ak Tom - "various items in the IN list"

+4
source

if you have APEX installed, the APEX_UTIL.string_to_table function does just that.

+3
source

PL / SQL does not come with a built-in tokenizer. However, it is relatively simple to build SQL or PL / SQL. The Adrian Billington website has several solutions . Also, if you're on 10g, you can use this code from Tanel Poder , which does this in SQL using a regular expression.

Admittedly, it would be easier if Oracle simply included the dang object as one of its built-in modules.

+2
source

An alternative is to write a Java stored procedure (there is a JVM in the database), which means you can use java.util.StringTokenizer. You must transfer the Java stored process inside the PL / SQL procedure / function.

Here for an example: http://forums.oracle.com/forums/thread.jspa?messageID=2575374�

Unfortunately, I do not understand the exceptions checked by Java, so the exception handling is not very great (I'm not a Java developer).

0
source

All Articles