Not sure if your DB supports this but with Oracle I can select the columns from the table.. select column_name from user_tab_columns where table_name = 'MY_TABLE' Granted this would require 2 trips to the database, 1 to get the column names, then check to see if your sortby variable is in that list, then another to actually query the table.
On 9/17/07, Brian Kotek <[EMAIL PROTECTED]> wrote: > On 9/17/07, Vince Collins <[EMAIL PROTECTED]> wrote: > > > > > > That suggestion works. However, in an example of a query with 10 > > columns and assuming you want to allow desc and asc, does anyone have a > > more conscience way other than 20 cfcase statements? > > > You could specify a list of table names and use ListFindNoCase(). Or you > could come up with an automatic solution by using JDBC metadata (or if/when > you switch the CF8, the CFDBINFO tag) to get the valid column names for the > table and compare the incoming order by value to those. You'd probably want > to do this once per table and cache the column names somewhere so you > wouldn't have to do it on every request. > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers and developers. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:288647 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4