oracle ORA - 02287 此处不允许使用序列号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17161265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA - 02287 sequence number not allowed here
提问by user1251973
I have a table name test which has three columns id, m_id and s_m_id
我有一个表名测试,它包含三列 id、m_id 和 s_m_id
I am executing below query
我正在执行以下查询
select id,test.nextval listagg(m_id || ',' || s_m_id, ';') within group (order by m_id) as merge_ids
from test t group by id
than I am getting error ORA - 02287 sequence number not allowed here.
比我收到错误 ORA - 02287 序列号这里不允许。
回答by Codo
You're trying to do too many things in one go. Create a subquery for the grouping and add the sequence numbers later:
你试图一次做太多事情。为分组创建一个子查询并稍后添加序列号:
select id, test.nextval, merge_ids
from (
select id, listagg(m_id || ',' || s_m_id, ';') within group (order by m_id) as merge_ids
from test t
group by id
)