Skip site navigation (1) Skip section navigation (2)

Sql ORDER BY and ASC/DESC question

From: "Jaroslav Sivy" <yarex(at)pobox(dot)sk>
To: pgsql-sql(at)postgresql(dot)org
Subject: Sql ORDER BY and ASC/DESC question
Date: 2008-01-30 10:35:51
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Hello everyone,

I have following problem: am using pl/sql functions to trigger some sql code and i need to pass ORDER_BY column name and ASC/DESC sorting order as an input parameters into that function
and order the result based on these input parameters.

The problem is, that the only way is to create query as "string" and then execute it as "string".

Is there any other way around how to avoid that "string query"?

(i don't want to use IFs either, because 5 columns x 2 sorting orders would require 10 IFfed queries with different column/sorting order combination)

If it's not possible, could anyone implement this feature into one of future versions? I think that it would be quite handy to have something like that.

Thank you for your responses.
------------------- - Denne aktualizovany zoznam obedovych menu a restauracii s presnou lokalizaciou. 


pgsql-sql by date

Next:From: A. KretschmerDate: 2008-01-30 10:42:26
Subject: Re: Sql ORDER BY and ASC/DESC question
Previous:From: Steve MidgleyDate: 2008-01-30 04:31:58
Subject: Re: Proposed archival read only trigger on rows - prevent history modification

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group