Sql 如何在“函数”中应用函数;在;条款

Sql 如何在“函数”中应用函数;在;条款,sql,oracle,sap,business-objects,Sql,Oracle,Sap,Business Objects,我有一个以这种格式返回值的值列表:“NAME-ID”。在宇宙中,我需要在我的表和用户选择的值之间进行连接,但我的问题是,在我的表中只存在ID列 我能够做到这一点: select t.column1, t.column2, ... from my_table t where t.id in regexp_substr(@prompt('1. Choose an element:', 'C', 'Elements\Identifiers', Mono, Free, not_persist

我有一个以这种格式返回值的值列表:“NAME-ID”。在宇宙中,我需要在我的表和用户选择的值之间进行连接,但我的问题是,在我的表中只存在ID列

我能够做到这一点:

select  t.column1, t.column2, ...
from    my_table t
where   t.id in regexp_substr(@prompt('1. Choose an element:', 'C', 'Elements\Identifiers', Mono, Free, not_persistent, ), '*[[:digit:]]+$')
使用正则表达式,我得到标识符的数字部分,“连接”工作正常,但现在我需要允许多重选择。所以,我的问题是:有一种方法可以将regexp\u substr应用于提示符返回的每个值

SQL翻译:(有办法做到这一点吗?)


我不确定在中如何使用
,除非使用递归CTE。但以下逻辑可能会起作用:

where @prompt('1. Choose an element:', 'C', 'Elements\Identifiers', Mono, Free, not_persistent
             ) like '%- ' || t.id

如果在
@提示符
定义中将
Mono
更改为
Multi
,则应该能够选择或输入多个值。然后,所选值将作为逗号分隔的列表返回,就像
子句中的
一样

因此,您的SQL语句将是:

select  t.column1, t.column2, ...
from    my_table t
where   t.id in regexp_substr(@prompt('1. Choose an element:', 'C', 'Elements\Identifiers', Multi, Free, not_persistent, ), '*[[:digit:]]+$')
select  t.column1, t.column2, ...
from    my_table t
where   t.id in regexp_substr(@prompt('1. Choose an element:', 'C', 'Elements\Identifiers', Multi, Free, not_persistent, ), '*[[:digit:]]+$')