“ORA-01791:不是SELECTed表达式” 问题的解决方法
发布日期:2021-06-29 21:09:22 浏览次数:2 分类:技术文章

本文共 636 字,大约阅读时间需要 2 分钟。

1 发现问题

oracle 中使用了带 distinct 的 SQL 语句,执行中抛出 “ORA-01791 不是SELECTed表达式”。

SQL 如下:

select distinct t.activity_name_,s.assignee_from jbpm4_hist_actinst t,jbpm4_hist_task swhere t.htask_=s.dbid_and t.type_='task'and s.execution_ ='LM.1000007489'and t.end_ is not nullorder by t.end_ desc

2 分析

原来 SQL 语句是先执行 distinct 去重后,再使用 order by 进行排序的。所以如果在 order by 需要排序的字段,没有在 distinct 后的字段中,自然会抛错。

3 解决

在 distinct 后加入需要排序的字段即可。

修复后的 SQL 语句如下:

select distinct t.activity_name_,s.assignee_,t.end_from jbpm4_hist_actinst t,jbpm4_hist_task swhere t.htask_=s.dbid_and t.type_='task'and s.execution_ ='LM.1000007489'and t.end_ is not nullorder by t.end_ desc

转载地址:https://deniro.blog.csdn.net/article/details/79024099 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:带你进入 jBPM 工作流的世界
下一篇:java.util.ConcurrentModificationException 异常的解决方法

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月17日 04时23分11秒