-- Тип массив строк для упрощения накапливания результата
create or replace editionable type varchar_array as table of varchar2(4000);

-- Таблица с ключевыми словами, все слова должны быть формата /СЛОВО/
create table keys (
	id integer,
	name varchar2(64)
)

create or replace procedure aaa (
	i_str in varchar2, -- Входная комбинация
	o_s1 out varchar2, -- Первый результат
	o_s2 out varchar2, -- Второй результат
	o_s3 out varchar2, -- Третий результат
	o_s4 out varchar2, -- Четвертый результат
	o_s5 out varchar2, -- Пятый результат
	o_s6 out varchar2 -- Шестой результат
) as
-- Счетчик числа найденных элементов
	v_n simple_integer := 0;
-- Массив найденных элементов
	v_r varchar_array := varchar_array();
-- Промежуточный буффер
	v_str varchar2(32000);
-- Временная строка
	v_t_str varchar2(32000);
begin
	v_str := i_str;
-- Перед всеми ключевыми словами в исходной строке добавляем разделитель (символ с кодом 1)
-- Это позволит нам разделять строку с автоучетом ключевых слов
	for i in (
		select
			name
		from
			keys
	) loop
		v_str := replace(v_str, i.name, chr(1)||i.name);
	end loop;
-- Все разделители // заменяем на разделитель chr(1)
	v_str := replace(v_str, '//', chr(1));
-- В цикле разбиваем строку по разделителю chr(1)
	for i in (
		select
			regexp_substr (s.s,'[^'||chr(1)||']+',1,level) as s
		from
			(select v_str as s from dual) s
		connect by
			level <= length (s.s)-length(replace(s.s,chr(1)))+1
	) loop
		if i.s is not null then
			v_t_str := i.s;
-- Т.к. ранее мы убрали все разделители //, то их надо вернуть для варианта когда у нас не ключевое слово и не первая найденная комбинация
			if v_n > 0 and substr(v_t_str,1,1) <> '/' then
				v_t_str := '//'||v_t_str;
			end if;
-- В цикле делим полученный результат на группы из 35 символов
			loop
				v_n := v_n + 1;
				v_r.extend();
-- Искоомая группа символов
				v_r(v_n) := substr(v_t_str,1,35);
-- Остаток
				v_t_str := substr(v_t_str,36);
-- Ограничение на опустошение строки и разбор до 6 слов
				exit when v_t_str is null or v_n >= 6;
			end loop;
		end if;
-- Ограничение на разбор до 6 слов
        exit when v_n >= 6;
	end loop;
-- Заносим полученный результат в выходные переменные
	if v_n > 0 then
		o_s1 := v_r(1);
	end if;
	if v_n > 1 then
		o_s2 := v_r(2);
	end if;
	if v_n > 2 then
		o_s3 := v_r(3);
	end if;
	if v_n > 3 then
		o_s4 := v_r(4);
	end if;
	if v_n > 4 then
		o_s5 := v_r(5);
	end if;
	if v_n > 5 then
		o_s6 := v_r(6);
	end if;
end;
 

PL/SQL Online Compiler

Write, Run & Share PL/SQL code online using OneCompiler's Oracle PL/SQL online editor and compiler for free. It's one of the robust, feature-rich online editor and compiler for Oracle PL/SQL running on latest version 23c (23.3.0.0). Getting started with the OneCompiler's Oracle PL/SQL editor is really simple and pretty fast. The editor shows sample boilerplate code when you choose language as 'PL/SQL' and start writing code to learn and test online without worrying about tedious process of installation.

About PL/SQL

PL/SQL is procedural extension for SQL created by Oracle. It is by default embedded into the Oracle Database. PL/SQL program units are compiled and stored inside the Oracle Database which results in optimal execution times as the PL/SQL and SQL run within the same server process.

Syntax help

Following is the syntax structure for the PL/SQL code blocks

DECLARE 
   <declarations section> 
BEGIN 
   <executable command(s)>
EXCEPTION 
   <exception handling> 
END;

Example

DECLARE 
   message  varchar2(100):= 'Hello, World!'; 
BEGIN 
   dbms_output.put_line(message); 
END; 
/

Named procedures

CREATE OR REPLACE FUNCTION 
hello_user
   (user_name IN VARCHAR2) 
    RETURN VARCHAR2
IS
BEGIN
   RETURN 'Hello ' || user_name;
END hello_user;
/

BEGIN
   dbms_output.put_line(hello_user('Peter'));
END;
/

Exception handling

BEGIN
  DBMS_OUTPUT.put_line (1/0);
EXCEPTION
  WHEN OTHERS
  THEN
    DBMS_OUTPUT.put_line ('error is: ' || SQLERRM);
END;