From: <[EMAIL PROTECTED]>
Subject: code to compare cfquery recordsets?
> Has anyone written a module to compare queries? I'd just like to know if
> two queries are identical or not, I don't care how they're different.
>
ValueList() will produce a list of values for a specified column
ListSort() on ValueList()
Replace() on ListSort() to remove delimiters and essentially
change to a string
use Compare() on stringed columns from q1 & q2
You could repeat for each column or decide that one specific
column is sufficient to test for congruency
You should do above for
query1.ColumnList compared to query2.ColumnList
first just to check that columns are same
Pseudocode for above ...
<cfset delim=chr(135)>
<cfset
query1_column1_string=Replace(ListSort(ValueList(column,delim)),delim,"")>
<cfset
query2_column1_string=Replace(ListSort(ValueList(column,delim)),delim,"")>
<cfset no_match=compare(query1_column1_string,query2_column1_string)>
<cfif(NOT no_match)>
<cfoutput>MATCH</cfoutput>
</cfelse>
<cfoutput>NO MATCH</cfoutput>
</cfif>
You can improve the above by looping over the .columnlist for each query
and producing a series of column_string vars and then set up a logic
for sequentially comparing corresponding values.
Sorry for not writing complete alorithm ... should be enough here to
provide for writing inline or tag-based code.
Pan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists