powered by simpleCommunicator - 2.0.52     © 2025 Programmizd 02
Форумы / Oracle [игнор отключен] [закрыт для гостей] / filter array string with a array string parameters
3 сообщений из 3, страница 1 из 1
filter array string with a array string parameters
    #39943263
gda
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
I have let's a table with the data that keep some IDs separated by comma.

Код: plsql
1.
2.
3.
4.
5.
6.
7.
with w0 as
(
select 1 as col1, '2,3,4,66,342,5' as col2 from dual union all
select 2 as col1, '1' as col2 from dual union all
select 3 as col1, '4,5,2,8,99,1' as col2 from dual 
)
select * from w0



I will createa procedure that will have a string parameter p_str that will keep the IDs list on which I want to filter.

For example if :
1. p_str = 1,99 then in the result - record 2 and 3
2. p_str = 342 then in the result - 1 record
3. p_str = 66,1,8 then in the result - all the records because all records keep these numbers

How can I compare a sub-value of string parameter to the values from the tables ?
...
Рейтинг: 0 / 0
filter array string with a array string parameters
    #39943267
Фотография -2-
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
gda,

regexp_like
...
Рейтинг: 0 / 0
filter array string with a array string parameters
    #39943286
Фотография SY
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
gda

How can I compare a sub-value of string parameter to the values from the tables ?


Не хранить множественные значения в одном поле. Just for fun:

Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
with w0 as
(
select 1 as col1, '2,3,4,66,342,5' as col2 from dual union all
select 2 as col1, '1' as col2 from dual union all
select 3 as col1, '4,5,2,8,99,1' as col2 from dual
)
select  distinct w0.*
  from  w0,
        xmltable(
                 col2
                 columns
                   x number path '.'
                ),
        xmltable(
                 '&p_str'
                 columns
                   y number path '.'
                )
  where x = y
/
Enter value for p_str: 1,99
old  15:                  '&p_str'
new  15:                  '1,99'

      COL1 COL2
---------- --------------
         2 1
         3 4,5,2,8,99,1

SQL> /
Enter value for p_str: 342
old  15:                  '&p_str'
new  15:                  '342'

      COL1 COL2
---------- --------------
         1 2,3,4,66,342,5

SQL> /
Enter value for p_str: 66,1,8
old  15:                  '&p_str'
new  15:                  '66,1,8'

      COL1 COL2
---------- --------------
         3 4,5,2,8,99,1
         2 1
         1 2,3,4,66,342,5

SQL>



SY.
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / Oracle [игнор отключен] [закрыт для гостей] / filter array string with a array string parameters
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]