Example Name: StatesEnum.cfc
Language: CFML
Version: 1.0.0
Code:
<cfcomponent>
<cffunction name="getAllStates" access="remote" returnType="Query">
<cfquery datasource="Northwind" name="allStates">
SELECT StateID, StateName, StateAbbr, StateRegion
FROM USStates
</cfquery>
<cfreturn #allStates# />
</cffunction>
<cffunction name="getStatesByRegion" access="remote" returnType="Query">
<cfargument name="region" type="string" required="true" />
<cfset allStates=this.getAllStates() />
<cfquery dbtype="query" name="regionalStates">
SELECT *
FROM allStates
WHERE StateRegion = '#region#'
</cfquery>
<cfreturn #regionalStates# />
</cffunction>
</cfcomponent>
Download code text
Download chapter example files