Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cflocation and cfcatch conflict 1

Status
Not open for further replies.

ironyx

Technical User
Nov 13, 2001
134
US
I am trying to do a cfcatch, but I have a cflocation which is supposed to work only if there is no error. I tried several cfif statements, but I seem to be messing up the logic and syntax a lot! Could someone at least show me some psuedo code so I have a good idea how I should be doing this, or if I am way off base with the way I am trying to handle the error?
I appreciate any time taken!
Va.

<cftry>
<cfquery datasource=&quot;cficapps&quot;>
update
C3SYS.C3_TEAMMEMBERSHIP_TBL
set
empid='#form.empid#',
level1='#form.level1#',
level2='#form.level2#',
level3='#form.level3#',
level1rank='#form.level1rank#'
where
empid='#URL.empid#' AND
level1='#URL.level1#' AND
level2='#URL.level2#' AND
level3='#URL.level3#' AND
level1rank='#URL.level1rank#'

</cfquery>
<cfcatch type=&quot;database&quot;>
<cfoutput><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
<h3><p>You are trying to create a duplicate record.</p></h3>
<p>Click <a href=&quot;Search.cfm&quot;>here</a> to return to Search page. <br/>
Click <a href=&quot;Menu.cfm&quot;>here</a> to return to Main Menu.</p>
</font></cfoutput>
</cfcatch></cftry>

<cflocation url=&quot;Search.cfm&quot;>
 
Place your <cflocation url=&quot;Search.cfm&quot;> above the cfcatch tag.

example:

<cftry>
<cfquery datasource=&quot;cficapps&quot;>
update
C3SYS.C3_TEAMMEMBERSHIP_TBL
set
empid='#form.empid#',
level1='#form.level1#',
level2='#form.level2#',
level3='#form.level3#',
level1rank='#form.level1rank#'
where
empid='#URL.empid#' AND
level1='#URL.level1#' AND
level2='#URL.level2#' AND
level3='#URL.level3#' AND
level1rank='#URL.level1rank#'

</cfquery>

<cflocation url=&quot;Search.cfm&quot;>

<cfcatch type=&quot;database&quot;>
<cfoutput><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
<h3><p>You are trying to create a duplicate record.</p></h3>
<p>Click <a href=&quot;Search.cfm&quot;>here</a> to return to Search page. <br/>
Click <a href=&quot;Menu.cfm&quot;>here</a> to return to Main Menu.</p>
</font></cfoutput>
</cfcatch></cftry>

 
try this
<cfcatch type=&quot;database&quot;>
<cfoutput><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
<h3><p>You are trying to create a duplicate record.</p></h3>
<p>Click <a href=&quot;Search.cfm&quot;>here</a> to return to Search page. <br/>
Click <a href=&quot;Menu.cfm&quot;>here</a> to return to Main Menu.</p>
</font></cfoutput>[red]<cfabort>[/red]
</cfcatch></cftry>
 
Actually switching the position of the statement worked. Thanks guys!
Va.
 
This is the way i would code it...
less chance of errors....

<cfparam name=&quot;variables.throwError&quot; default=&quot;FALSE&quot;>
<cfcatch type=&quot;database&quot;>
<cfset variables.throwError = TRUE>
<font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;>
<h3><p>You are trying to create a duplicate record.</p></h3>
<p>Click <a href=&quot;Search.cfm&quot;>here</a> to return to Search page. <br/>
Click <a href=&quot;Menu.cfm&quot;>here</a> to return to Main Menu.</p>
</font>
</cfcatch>
</cftry>

<cfif not variables.throwError>
<cflocation url=&quot;Search.cfm&quot;>
</cfif>
------------------------------------------------------------------------------
brannonH
if( !succeed ) try( );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top