Listing 1

<cffunction name="GetAllDepartments" access="public" returntype="array" output="false">
		<cfargument name="dsn" required="true" type="string">
		<cftry>
			<cfquery name="GetAll" datasource="#arguments.dsn#">
				SELECT
					id
				FROM
					Department
			</cfquery>

			<cfscript>
				DepartmentArray = ArrayNew(1);

				//if no departments found, throw an error
				if(GetAll.RecordCount eq 0)
				{
					ThrowError('No departments found.');
				}

				for(i = 1; i lte GetAll.RecordCount; i = i + 1)
				{
					ArrayAppend(DepartmentArray,GetAll['id'][i]);
				}

				return DepartmentArray;
			</cfscript>
		<cfcatch type="database">
			<cfthrow message="There was an error communicating with the database server.
			 Please call the help desk at x555.">
		</cfcatch>
		<cfcatch type="any">
			<cfthrow message="#cfcatch.Message#">
		</cfcatch>
		</cftry>
	</cffunction>