You could write a set of expressions that yield proper order by field
in one case and say null in another. Say we want order by columns
if the first function argument is '1' and by if it is '2', this can be achieved as:
select col1, col2, col3 from mytable
where ...
order by case when $1 = '1'
> Not that I've ever heard of. Well, you move the procedure up into
> the application level but inside the database you'll need a procedure
> to handle the branching on the argument values with each branch
The thing is that it's internal query and its result isn't retuned
from the procedure.
> Y
On Nov 21, 2007, at 9:48 AM, Sergey Konoplev wrote:
Hello,
I have a procedure which takes few arguments. The arguments must
affect expressions set of "order by" clause. For instance in one case
ordering must be performed by 1st, 2nd (desc) and 3rd fields but in
another by 3rd, 1st and 2nd field
Hello,
I have a procedure which takes few arguments. The arguments must
affect expressions set of "order by" clause. For instance in one case
ordering must be performed by 1st, 2nd (desc) and 3rd fields but in
another by 3rd, 1st and 2nd fields.
Is there a way to manage it without using dynamic q