Question:
How do I split a string by checking for a number of bytes in the string?
Summary:
For example, I have a string with a length of 6000 bytes and I have a table with a column named 'BODY' with the type VARCHAR2(4000).
SQL> DESCRIBE TAB_DDA_STORED_CODE;
Name Null? Type
----------------------------------------- -------- ----------------------------
CHANGE_ID NOT NULL NUMBER
BODY NOT NULL VARCHAR2(4000)
LINE NOT NULL NUMBER
What I need to do is check the length of the string and then parse/split the string by a number of bytes.
Thus, relating to the table above, when I run the following SQL, it inserts the first 4000 bytes of the string in a record and the rest of the 2000 bytes in another record.
INSERT INTO TAB_DDA_STORED_CODE (change_id, body, line)
VALUES (:CHANGE_ID, :VIEW_TEXT, :LINE);
Therefore, I would have the following two records similar to:
CHANGE_ID BODY LINE
--------- --------- ----
1 (4000 bytes) 1
1 (2000 bytes) 2
Has anyone done anything similar to this before? I believe I could use str_split and use the returned array as the parameters for my SQL Insert statement.
Any suggestions, examples or thoughts are greatly appreciated.
Thank you!