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;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.