Patrick,
Thanks. Think it does the same thing.
Oops!
*Message* Invalid data {CountyID={2}} for CFSQLTYPE CF_SQL_CHAR.
*Detail*
*Extended Info*
*Tag Context* C:\ColdFusion8\wwwroot\Reactor\base\abstractGateway.cfc (92)
byron
Patrick McElhaney wrote:
Try this:
fields = structNew();
fields['county'] = 2;
getParticipantGateway().getByFields(fields);
I think ColdFusion is taking getByFields(#fieldlist#) and reducing it
to getByFields(fieldlist) which ends up as getByFields("County=2").
Patrick
On 9/25/07, Byron Raines <[EMAIL PROTECTED]> wrote:
I have a weird problem. I'm using the getByFields() method on a gateway.
getParticipantGateway().getByFields(County=2)
I get back the expected results. However, I am constructing the
parameter programatically, so I have:
getParticipantGateway().getByFields(#fieldlist#) where fieldlist is
"County=2".
When I run it I get the following error:
Oops!
*Message* The cause of this output exception was that:
coldfusion.tagext.sql.QueryParamTag$InvalidDataException: Invalid data
value CountyID=2 exceeds maxlength setting 5..
*Detail*
*Extended Info*
*Tag Context*
C:\ColdFusion8\wwwroot\Reactor\project\HopeWorks\Queries\mssql_4289702D0613A72FF692C035734D311D.cfm
(1)
Further inspection of the query file reveals the following:
SELECT [tblParticipant].[Pt_ID] AS [Pt_ID], [tblParticipant].[Phase]
AS [Phase], [tblParticipant].[CountyID] AS [CountyID],
[tblParticipant].[Firstname] AS [Firstname],
[tblParticipant].[Lastname] AS [Lastname], [tblParticipant].[Address]
AS [Address], [tblParticipant].[City] AS [City],
[tblParticipant].[State] AS [State], [tblParticipant].[ZipCode] AS
[ZipCode], [tblParticipant].[Phone] AS [Phone],
[tblParticipant].[CircleLeaderID] AS [CircleLeaderID],
[tblParticipant].[ConsentDate] AS [ConsentDate],
[tblParticipant].[CircleLeader] AS [CircleLeader],
[tblParticipant].[CC_ID] AS [CC_ID], [tblParticipant].[GroupID] AS
[GroupID], [tblParticipant].[Status] AS [Status],
[tblParticipant].[PARQ] AS [PARQ], [tblParticipant].[MedicalForm] AS
[MedicalForm], [tblParticipant].[DateMedicalFormReturned] AS
[DateMedicalFormReturned], [tblParticipant].[FUSurveyDate] AS
[FUSurveyDate], [tblParticipant].[Cortisol] AS [Cortisol],
[tblParticipant].[Notes] AS [Notes] FROM [tblParticipant] AS
[tblParticipant] WHERE [tblParticipant].[Pt_ID] = <cfqueryparam
cfsqltype="cf_sql_char" maxlength="5"
value="#arguments.Query.getValue(1)#" />
Is there a way to dynamically construct the parameter to go in the
method. For example: I might dynamically create "County=2,Group=1".
I'm trying to keep from having to have different functions for each
possible combination of filter variables.
Here is the function I'm using:
<cffunction name="getParticipants" access="public"
returntype="query" output="false">
<cfargument name="CountyID" type="numeric" required="false" />
<cfargument name="GroupID" type="numeric" required="false" />
<cfargument name="CircleLeaderID" type="string" required="false" />
<cfset fieldlist = "" />
<cfloop collection="#arguments#" item="key">
<cfif StructKeyExists(arguments,key)>
<cfset
fieldlist=ListAppend(fieldlist,"#key#=#arguments[key]#")>
</cfif>
</cfloop>
<cfreturn getParticipantGateway().getByFields(#fieldlist#) />
</cffunction>
Any help would be appreciated.
Byron
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --