-
hihi...
I have a user-defined TYPE as follow....
//
TYPE TEST_CENTER_TAB IS TABLE OF VARCHAR(2)
INDEX BY BINARY_INTEGER;
//
This TYPE is used to store an array of binary integer. I have a string "1,0,0,1,0,1". This string will be disconcatenated using the delimiters ",". Each of the disconcatenated integer will then be inserted in the newly defined TYPE "TEST_CENTER_TAB" that is having the type "TABLE".
Does anyone know how this can be done? Thanks.
cheers
-
Hope this is what you're looking for :)
CREATE OR REPLACE PROCEDURE parsestring (pi_stringtoparse IN VARCHAR2)
IS
TYPE test_center_tab IS TABLE OF VARCHAR (2) INDEX BY BINARY_INTEGER;
v_testcenter_tab test_center_tab;
v_strstart NUMBER;
v_commapos NUMBER;
v_strlen NUMBER;
i NUMBER;
BEGIN
i := 1;
v_strstart := 1;
LOOP
v_commapos := INSTR (pi_stringtoparse, ',', 1, i);
IF v_commapos > 0
THEN
v_strlen := v_commapos - v_strstart;
v_testcenter_tab (i) :=
SUBSTR (pi_stringtoparse, v_strstart, v_strlen);
i := i + 1;
v_strstart := v_commapos + 1;
ELSE
v_strlen := LENGTH (pi_stringtoparse) - v_strstart + 1;
v_testcenter_tab (i) :=
SUBSTR (pi_stringtoparse, v_strstart, v_strlen);
EXIT;
END IF;
END LOOP;
FOR j IN v_testcenter_tab.FIRST .. v_testcenter_tab.LAST
LOOP
DBMS_OUTPUT.put_line (v_testcenter_tab (j));
END LOOP;
END parsestring;
/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|