0

I want to allow sort to parameterized in a query, field id and order

so I have select .... order by @sortcol

then what? How to I use a parameter to indicate asc vs desc?

Using c# npgsql library.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
pm100
  • 48,078
  • 23
  • 82
  • 145
  • What is the context? What language/library/... are you using to talk to the database? You generally can't use placeholders for identifiers and SQL language elements so you're probably left with string manipulation. – mu is too short May 02 '18 at 18:10
  • @muistooshort updated question – pm100 May 02 '18 at 18:29
  • Easiest way is to add Order By clause with string concatenation or use stored procedure. Here someone had similiary question https://stackoverflow.com/questions/8139618/postgresql-parameterized-order-by-limit-in-table-function – Lemjur May 02 '18 at 18:38

0 Answers0