Alright I have a PLUM app that has 2 DSN connections.
I added the seconf one in enviornment.cfm as follows
Application.db2DSN = "INSIGHT";
Application.db2Username = "user";
Application.db2Password = "pass";
I have a page that I need to query the added DSN.
Here is a query I use.
<cfquery datasource="#application.db2DSN#" name="qry_memoryimport">
SELECT R_DIMMSlots.DeviceName,
R_DIMMSlots.MemorySize
FROM R_Inventory INNER JOIN R_DIMMSlots
ON R_Inventory.DeviceName = R_DIMMSlots.DeviceName
WHERE R_Inventory.SerialNumber = '#URL.SN#'
</cfquery>
But what I want to use is..
<cfscript>
selectClause = "R_DIMMSlots.DeviceName, R_DIMMSlots.MemorySize";
fromClause = "R_Inventory INNER JOIN R_DIMMSlots ON R_Inventory.DeviceName = R_DIMMSlots.DeviceName";
whereClause = "R_Inventory.SerialNumber = '#URL.SN#''";
qry_memoryimport = Application.DatabaseBlocks.SelectRecords(selectClause:selectClause,
fromClause:fromClause, whereClause:whereClause);
</cfscript>
Problem is where do I specify the DSN since it defaults to in the cfc to #application.db2DSN#.
Proposed solution is to add new arguments to databaseblocks.cfc
<cfargument name="DSNName" type="string" required="No" default="#Application.dbDSN#">
<cfargument name="DSNUsername" type="string" required="No" default="#Application.dbUsername#">
<cfargument name="DSNPassword" type="string" required="No" default="#Application.dbPassword#">
Change
<cfquery name="queryResult"
datasource="#Application.dbDSN#"
username="#Application.dbUsername#"
password="#Application.dbPassword#"
cachedWithin="#Arguments.cacheTimeSpan#">
to
<cfquery name="queryResult"
datasource="#Attributes.DSNName#"
username="#Attributes.DSNUsername#"
password="#Attributes.DSNPassword#"
cachedWithin="#Arguments.cacheTimeSpan#">
My query would know (hopefully) work like this
<cfscript>
DSNName = "#application.db2DSN#";
DSNUserName = "#Application.db2Username#";
DSNPassword = "#Application.db2Password#";
selectClause = "R_DIMMSlots.DeviceName, R_DIMMSlots.MemorySize";
fromClause = "R_Inventory INNER JOIN R_DIMMSlots ON R_Inventory.DeviceName = R_DIMMSlots.DeviceName";
whereClause = "R_Inventory.SerialNumber = '#URL.SN#''";
qry_memoryimport =
Application.DatabaseBlocks.SelectRecords(DSNName:DSNName,
DSNUsername:DSNUsername,
DSNPassword:DSNPassword,selectClause:selectClause,
fromClause:fromClause, whereClause:whereClause);
</cfscript>
Thoughts or opinions? Is there a better way?
--
Tim Blankenship
[EMAIL PROTECTED]
www.vespri.com
- [plum] databaseblocks DSN question - Alter Framework Tim Blankenship
