Browsing all articles from February, 2010
Feb
17

Tip : Getting unsorted query columns in coldfusion

Author nerdscubecom    Category Coldfusion     Tags , , , , ,

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() )>
Feb
9

Tip : Show hide columns in cfdump

Author nerdscubecom    Category Coldfusion     Tags

Small tip for the day, In Coldfusion MX7 the CFdump was pritty much dump that it just do the variable dump and nothing more.

CF8 dump is much more capable like writing the dump out to file like i did in my last blog , plus you even can control the fields that you need to show or hide during the dump. This could pretty much save time when dumping big queries which contains long columns
Continue reading “Tip : Show hide columns in cfdump” »

Take it with you!

Twitter

Recent Posts

Categories

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

RSS CF Libs

  • arrayTrim January 31, 2012
    This method trims an array to the specified number of elements. […]
  • longTime January 25, 2012
    Returns a list like 3 years, 2 months, 12 days, 1 hour, 10 minutes, 45 seconds from a seconds count argument. […]
  • quickSort January 15, 2012
    Implementation of Hoare's Quicksort algorithm for sorting arrays of arbitrary items. […]
  • GetHostAddress January 12, 2012
    Performs a DNS lookup. […]
  • GetFileFilterCount January 4, 2012
    Accepts a directory path & a file filter. Returns number of matching files. […]
  • replaceSpecialChars January 4, 2012
    Replaces all special characters in a string of text. […]
  • solrClean December 30, 2011
    Like VerityClean, massages text input to make it Solr compatible. […]
  • rjustify2 December 21, 2011
    Same as built-in RJUSTIFY, but allows optional parameter character to pad with. […]
  • RowColor December 21, 2011
    Returns alternating color based on list of colors. […]
Get Adobe Flash playerPlugin by wpburn.com wordpress themes