Browsing all articles tagged with sorting
Tip : Getting unsorted query columns in coldfusion
This one gave me a headache for 15 min, making all the possible tricks to make my query return the unsorted columns.
Generally Coldfusion always sort the columns in the query that has been returned, irrespective of the order you have specified in the SQL statement. Most of the time its a blessing, but not always.
There is no documented way to get the unsorted columns otherthan using some thirdparty customtags and function. But there is a tweak for this case.
Tweak #1
Use getMetaData() function to get the column list which is as per the sql statement which you have written.
<!--- use GetMetadata to get the names and data types of the fields in the cfdocexamples Employees table ---> <cfquery name="getemployees" datasource="cfdocexamples"> SELECT * FROM Employees </cfquery> <cfset employeemeta=getMetaData(getemployees)> <h4>The Employees table has the following columns</h4> <cfloop index="i" from="1" to="#arrayLen(employeemeta)#"> <cfoutput> #employeemeta[i].name# </cfoutput> </cfloop>
Tweak#2
Use queryObj.getColumnNames() function to get the unsorted list of column from the query. this function is not documented in CF docs. Thanks to Richard
<cfset queryColumnlist = ArrayToList( qryObj.getColumnNames() )>Take it with you!
Recent Posts
- Instant Method Finder : My first Coldfusion Builder extension!
- Create coldfusion builder snippets from cflib repository
- Tip:Difference between resistive and capacitive touch screen.
- Why QR code is cool and easy with smartphones !!!!!
- Tip : Getting unsorted query columns in coldfusion
Categories
- Coldfusion
- Coldfusion Builder
- HTML
- Javascript
- Jquery
- Movies
- Project Management
- Technology
- Tips and Tricks
- whatsNew
Tags
Adventure
Android
augmented
Augumented
avatar
cf8
CF9
cfdump
cfquery
Coldfusion
Coldfusion programming technology features new
compare
comparison
debugging
Definitions
design
Digitization
dynamic
element creation
form
future
getmetadata
HTML
Inspirations
Iphone
Javascript
Jquery
movie
Movies
mustwatch
mx7
new feature
programming
project
Project Management
Reality
realtime
si-fi
Technology
tip
top
tricks
validation
virtual world
web development
Archives
- January 2011 (2)
- October 2010 (2)
- February 2010 (2)
- January 2010 (5)
- December 2009 (5)
CF Libs
- getComponentProps May 18, 2012Returns an array of all properties in cfc's metadata, inherited or not. […]
- iniToStruct April 26, 2012Converts ini file(s) to a struct. […]
- deDupeArray April 26, 2012Removes duplicate values from an array. […]
- dice April 24, 2012Divide a string in parts of equal size with separators in between/ […]
- getRelative April 9, 2012Returns a relative path from the current template to an absolute file path. […]
- excelRate February 23, 2012Returns the interest rate per period of an annuity. […]
- arrayTrim January 31, 2012This method trims an array to the specified number of elements. […]
- longTime January 25, 2012Returns a list like 3 years, 2 months, 12 days, 1 hour, 10 minutes, 45 seconds from a seconds count argument. […]
- quickSort January 15, 2012Implementation of Hoare's Quicksort algorithm for sorting arrays of arbitrary items. […]

nerdscubecom
