Hal:
Back in the days of MVS, PL/1 and DB2 (oh yeah, those days are still here)
as we progressed from BDAM, VSAM, ISAM, IOmods, LVARs and flintlocks, the
Entity Access Module (EAM) became the paradigm for (DB2) database access. I
use this for my ColdFusion database accesses also.
The qry_database_table_name.cfm file contains all of the SQL necessary for
the allowed table access (i.e, sometimes "Insert", "Update" and/or "Delete"
are missing.) This means the fuse has to handle the determination of the
need for an EAM call. Most of these EAM calls are well-hidden from the
index.cfm.
In the example below, the unit of work, act_update_referral.cfm has 4
explicit qry_... calls and a couple of implicits.
NOTE (OT): I wanted to use debug as a variable for qry_... but debug becomes
"Yes" no matter what value is sent.
-------------------index.cfm
..
..
..
<CFCASE VALUE="update_referral">
<!--- sub-fuse for updating a referral --->
<cfset request.help_page = "002">
<cfset variables.return_code = 0>
<CFTRY>
<CFINCLUDE TEMPLATE="act_update_referral.cfm">
<CFCATCH TYPE="Any">
<!--- just need to slow the error down so that
url_update_referral can handle it. --->
</CFCATCH>
</CFTRY>
<CFINCLUDE TEMPLATE="url_update_referral.cfm">
</CFCASE>
..
..
..
-------------------act_update_referral.cfm
..
..
..
<CFSCRIPT>
variables.poNumber = variables.currPONumber;
variables.accountNumber = variables.currAccountNumber;
variables.call_indicator = attributes.SQLselect;
variables.poCount = 0;
variables.selectClause = " COUNT(*) AS CHECKPOCOUNT";
variables.DBname = "Purchase Order";
variables.theName = "check_PO";
variables.return_code = 0;
</CFSCRIPT>
<CFMODULE TEMPLATE="../qry_poinfo.cfm">
..
..
..
--------------------qry_poinfo.cfm
..
..
..
<CFIF NOT IsDefined("caller.call_indicator")>
<CFSET variables.qryRC = 1>
<CFELSE>
<CFSWITCH EXPRESSION="#caller.call_indicator#">
<CFCASE VALUE="1">
<CFIF NOT IsDefined("caller.selectClause")>
<CFSET variables.qryRC = 2>
<CFELSEIF NOT IsDefined("caller.whereClause")>
<CFSET variables.qryRC = 3>
<CFELSEIF NOT #Find(";",caller.selectClause)# EQ 0>
<CFSET variables.qryRC = 4>
<CFELSEIF NOT #Find(";",caller.whereClause)# EQ 0>
<CFSET variables.qryRC = 5>
<CFELSE>
<CFIF isDefined("caller.theName")>
<CFSET variables.theName =
#caller.theName#>
<CFELSE>
<CFSET variables.theName =
"selectPO">
</CFIF>
<CFQUERY NAME="CALLER.#variables.theName#"
DATASOURCE="#REFDBSOURCE#"
BLOCKFACTOR="#caller.theBlockFactor#"
CACHEDWITHIN="#caller.theCachedWithin#">
SELECT #caller.selectClause#
FROM WR.PURCHASE_ORDER
#preserveSingleQuotes(caller.whereClause)#
</CFQUERY>
------------------------------------------------
>
> Folks,
>
> Question on how you handle queries: Some people always include query files
> in other files, like this in actDoSomething.cfm:
>
> <cfinclude template="/Queries/aQuery.cfm">
>
> Others let the fusebox itself handle this, like this:
>
> <cfcase value="doSomething">
> <cfinclude template="actDoSomething.cfm">
> <cfinclude template="aQuery.cfm">
> </cfcase>
>
> My question is this: if you use the second method, how do you handle the
> situation where you would only want to call "aQuery.cfm" IF a variable in
> "actDoSomething.cfm" was set to true? Do you do it in the fusebox, like
> this:
>
> <cfcase value="doSomething">
> <cfinclude template="actDoSomething.cfm">
> <cfif includeQuery>
> <cfinclude template="aQuery.cfm">
> </cfif>
> </cfcase>
>
> Or do you do something else? I'm just trying to see how different
> developers
> handle this situation.
> Hal Helms
>
> Team Allaire
>
> [ See www.halhelms.com for info on training classes ]
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists