Oracle 排序替换变量
我需要对替换变量进行排序,以便稍后可以像这样引用它们:
WITH
vars AS (SELECT SORT(:var1,:var2, :var3) FROM DUAL)
SELECT least_var, greater_var, greatest_var FROM vars;
I need to sort substitution variables so I can refer to them later like this:
WITH
vars AS (SELECT SORT(:var1,:var2, :var3) FROM DUAL)
SELECT least_var, greater_var, greatest_var FROM vars;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您有替换变量,因此显然您有一些宿主语言。因此,一种方法是在调用 SQL 查询之前以宿主语言对三个值进行排序。
另一种方法是使用以下查询(例如与WITH子句结合使用):
按照您的建议创建SORT函数不会真正起作用,因为函数无法返回充当三列的构造。如果您想使用函数,请使用其中三个:内置函数 LEAST 和 GREATEST 以及用户定义的函数 GREATER。
Since you have substitution variables, you obviously have some host language. So one approach is to order the three values in the host language before you call the SQL query.
Another approach is to use the following query (e.g. in combination with the WITH clause):
Creating a SORT function as you propose won't really work as a function cannot return a construct that serves as three columns. If you want to use functions, then use three of them: the built-in functions LEAST and GREATEST as well as a user-defined one called GREATER.