When writing a stored procedure, a split string is used. The first input parameter is a string with a delimiter and the second parameter is the number of delimiters. The following is a single-Proposed string splitting method,
Create or replace procedure split (
I _pageids in varchar2, -- the original page pageid group, which is passed in as a string, for example, 1001,1511,
I _pageidscount in number -- number of pageids (also the number of comma separators, remember to add a comma at the end of the string)
)
Is
V_pageid number (20); -- save the value in the split string
V_ I number (20); -- index in the loop
V_strlength number (20); -- truncates the string length.
V_startindex number (20); -- start position of the truncated string
V_tempindex number (20); -- start position of the last string to be truncated
Begin
-- Obtain all pageids in the pageid string cyclically
For V_ I in 1 .. I _pageidscount Loop
If (V_ I = 1)
Then
V_startindex: = 1;
V_strlength: = instr (I _pageids, ',', 1, 1)-1;
Else
V_tempindex: = instr (I _pageids, ',', 1, v_i-1 );
V_strlength: = instr (I _pageids, ',', 1, V_ I)-v_tempIndex-1;
V_startindex: = v_tempindex + 1;
End if;
-- Get the pageid value in the page Array
V_pageid: = to_number (substr (I _pageids, v_startindex, v_strlength ));
-- V_pageid is the value after splitting.
End loop;
End split;