I have such table function with one parameter of CLOB data type
CREATE TYPE clob_tab AS TABLE OF CLOB;
/
create or replace FUNCTION process_clob (clob_val IN CLOB )
RETURN clob_tab
IS
v_clob clob_tab := clob_tab();
v_count NUMBER := 0;
v_num NUMBER;
v_start PLS_INTEGER;
v_next PLS_INTEGER;
v_delim PLS_INTEGER;
v_len PLS_INTEGER;
BEGIN
v_start := 1;
LOOP
v_next := 0;
v_delim := DBMS_LOB.INSTR( clob_val, ',', v_start );
IF v_delim > 0 AND (v_next = 0 OR v_delim < v_next) THEN
v_next := v_delim;
END IF;
v_delim := DBMS_LOB.INSTR( clob_val, ';', v_start );
IF v_delim > 0 AND (v_next = 0 OR v_delim < v_next) THEN
v_next := v_delim;
END IF;
v_delim := DBMS_LOB.INSTR( clob_val, '|', v_start );
IF v_delim > 0 AND (v_next = 0 OR v_delim < v_next) THEN
v_next := v_delim;
END IF;
v_len := CASE v_next WHEN 0 THEN LENGTH( clob_val ) + 1 ELSE v_next END - v_start;
-- Add the substring to the result table
v_clob.extend();
v_clob(v_clob.count) := SUBSTR( clob_val, v_start, v_len );
EXIT WHEN v_next = 0;
-- Move to the next position after the delimiter
v_start := v_next + 1;
END LOOP;
RETURN v_clob;
END process_clob;
select * from process_clob ( :val )
it is working as expected but I wonder what happens if I run the select statement in SQL Developer. Not using Run as Script but Run as statement.
a popup will open to enter values for bind variable. My question is if what data type is this bind variable.
I can enter some comma delimited string like abc,xyz and get the values in one column separated in rows. but If I try to enter something from Excel like this, it is a string and comma together of 16 characters.
It works fine till I try to enter more than 1820 rows. Then I get this error message
First I thought maybe the bind variable is of data type varchar2( 32767 bytes) but 16 characters times 1821 rows = 29136. It obviously does nothing to do with it. what is the reason for that. Is it just a limit in SQL Developer in the popup? What type is the bind variable?
I need to run it as statement and not a script because of some other joins and need the output as table with columns.