Solved

ColdFusion Validate a Number to Prevent Duplicates

Posted on 2009-04-03
8
207 Views
Last Modified: 2013-12-16
Hello,  I have a ColdFusion form that I need to validate a unique casenumber in an Oracle Database "onBlur" or (somehow prior to the form being submitted to the database).  Can I do this with ColdFusion alone or will I need to incorporate JavaScript?   Is there a best method before I start coding?
0
Comment
Question by:trizzle29
  • 4
  • 4
8 Comments
 

Author Comment

by:trizzle29
ID: 24059396
Here is the textfield
<cfinput type="text"
name="casenumber"
size="30"
required="yes"
onvalidate="???"
message="Please enter your Project Case Number!">
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24060822
Unique in what context?  ie
1. Unique in the Oracle database or ...
2. You have 4 fields and you need to verify they all contain a unique number?

If it is #1, the only bullet proof way to do that is within a database query. If #2, you can use javascript.
0
 

Author Comment

by:trizzle29
ID: 24060861
Thanks for your response.
It is #1
With this method is it possible to verify in Coldfusion through query and have the response received (onBlur) prior to submitting the data to the database?  I am trying to prevent the client from entering a duplicate casenumber and receiving the coldfusion error since the casenumber is the primary key.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24061006
You could use some Ajax to preform a pre-check before submitting the form.  BUT  ... there is no guarantee the case number won't be used in between the time you do the check and do the database insert.  The only bullet proof way is put a cftry/cfcatch around the query to catch the constraint violation. Then display a message if the case number is already in use ie "Please try again"...
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:trizzle29
ID: 24061025
I will try this and let you know how it turns out.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 24061057
Okay.  I take it the Case Number is not something you can generate automatically. That would avoid the whole issue.
0
 

Author Comment

by:trizzle29
ID: 24061306
Unfortunately the casenumber is assigned in a department that does not want to participate in the automation process.  
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 24061567
Yes, that is what I figured.   Then the try/catch is your best bullet proof option.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now