Skip to main content
Inspiring
December 25, 2007
Question

cfqueryparam question

  • December 25, 2007
  • 2 replies
  • 228 views
I started changing some of my queries to include the use of the
<cfqueryparam> option, as shown below:

<!--- Check to make sure url.tid exists and that it is numeric --->
<cfif not structkeyexists(url,"tid") and not isnumeric(url.tid)>
<cflocation addtoken="no" url="../club_tournaments.cfm">
</cfif>

<cfquery name="Confirmed" datasource="SB">
select u_fName,
u_lName,e_foil,u_club,u_uuid,e_foil_rating,e_foil_year,tournevent.e_epee,e_epee_rating,e_epee_year,c_full_name
from tournfencer left outer join tournevent
on tournfencer.u_id=tournevent.e_id
left outer join tournclub
on tournfencer.u_club=tournclub.c_name
where e_tid=<cfqueryparam cfsqltype="cf_sql_integer" value="#url.tid#"
maxlength="3">
order by u_lName
</cfquery>

Now if I enter something longer than three integers in length (just as a
test), I get a error message that looks like:

The cause of this output exception was that:
coldfusion.tagext.sql.QueryParamTag$InvalidDataException: Invalid data
2294 value exceeds MAXLENGTH setting 3..

Is there any way to make the error message look a little more pleasing
to the eye??
    This topic has been closed for replies.

    2 replies

    Inspiring
    December 25, 2007
    > If the maximum length for your integer data is 3

    I wonder if that means the lowest allowable negative integer in this case
    is -99 or -999? I presume the latter, but validating an integer on
    *length* seems a bit weird.

    --
    Adam
    Inspiring
    December 25, 2007
    > Is there any way to make the error message look a little more pleasing
    > to the eye??

    There is no special trick here. Validate your data, rather than just
    letting the code fall through to a point where the data will cause an
    error.

    If the maximum length for your integer data is 3, then perhaps you should
    make sure it *is* less than 999 before you try to put it into the DB. And
    if it's not less than 999... tell the user.

    --
    Adam