Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

Error Handling for CFQUERYPARAM

$
0
0

Is there a way to display the value of cfqueryparam upon a database error?  For example:

 

<cfquery name="causeError" datasource="#application.dsn#">

      select street1 from house, #table2# where house.houseid = #table2#.houseid and house.houseid = #form.houseid#

</cfquery>

 

The variable table2 is dynamically generated and let's say an error is caused table2 being an empty string or a table that doesn't exist.  So the error given is:

 

[Macromedia][Oracle JDBC Driver][Oracle]ORA-00903: invalid table name

 

4 : <cfquery name="causeError" datasource="#application.dsn#">

5 : select street1 from house, #table2# where house.houseid = #table2#.houseid and house.houseid = #form.houseid#

6 : </cfquery>

SQL   select street1 from house, where houseid = 123;

 

So I know that the user was trying to look at a house with houseid = 123.  I can then try to replicate the error using the same record in the database which can ultimately can help me diagnose the problem more quickly.


However, if I use cfqueryparam, i.e.:

 

<cfquery name="causeError" datasource="#application.dsn#">

      select street1 from house, #table2# where house.houseid = #table2#.houseid and house.houseid = <cfqueryparam value="#form.houseid#" cfsqltype="cf_sql_integer">

</cfquery>

 

I get:

 

[Macromedia][Oracle JDBC Driver][Oracle]ORA-00903: invalid table name

 

4 : <cfquery name="causeError" datasource="#application.dsn#">

5 : select street1 from house, #table2# where house.houseid = #table2#.houseid and house.houseid = <cfqueryparam value="#form.houseid#" cfsqltype="cf_sql_integer">

6 : </cfquery>

SQL   select street1 from house, where house.houseid = .houseid and house.houseid = (param 1)

 

I have no idea what the user entered.


Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>