/* Formatted on 3/4/2015 12:32:08 AM (QP5 v5.126) */
DECLARE
l_input VARCHAR2 (4000) := ‘1,2,3’;
l_count BINARY_INTEGER;
l_array DBMS_UTILITY.lname_array;
BEGIN
SELECT param_value
INTO l_input
FROM item_param_detail
WHERE param_value LIKE ‘TO%,%’;
DBMS_UTILITY.comma_to_table (
list => REGEXP_REPLACE (l_input, ‘(^|,)’, ‘\1x’),
tablen => l_count,
tab => l_array);
DBMS_OUTPUT.put_line (l_count);
FOR i IN 1 .. l_count
LOOP
DBMS_OUTPUT.put_line( ‘Element ‘
|| TO_CHAR (i)
|| ‘ of array contains: ‘
|| SUBSTR (l_array (i), 2));
END LOOP;
END;
Tách chuỗi thành mảng trong oracle
/* Formatted on 3/4/2015 12:32:08 AM (QP5 v5.126) */ DECLARE l_input VARCHAR2 (4000) := ‘1,2,3’; l_count BINARY_INTEGER; l_array DBMS_UTILITY.lname_array; BEGIN SELECT param_value INTO l_input FROM item_param_detail WHERE param_value LIKE ‘TO%,%’; DBMS_UTILITY.comma_to_table ( list => REGEXP_REPLACE (l_input, ‘(^|,)’, ‘\1x’), tablen => l_count, tab => l_array); DBMS_OUTPUT.put_line (l_count); FOR i IN 1 .. l_count LOOP DBMS_OUTPUT.put_line( ‘Element … Read more