|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
I'm having a problem in comparing the values, which I'm passing to the action page. My condition is I'll have to check for the values which I'm passing to the action page to the values in the database. when I'm comparing I'm getting only the first row in the database and I'll have to run a loop to check the exact values and display a error message."data already exit and ..." any body help me out how to run a loop query to check the values from the form passed in the action page? your help would be highly appreciated. Thanks |
|
#2
|
|||
|
|||
|
I don't understand what you're asking.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
checking values
I'm passing three form variables values to the action page.In the action page before inserting into the database, it should check for the existance of the values in there or not in the database.If so it should throw an error and if not it should allow to insert.
How to check the values with the database whether existing or not with the values? Thanks |
|
#4
|
|||
|
|||
|
Some more details about your db/ would help a bit. But lets say for example your db has one field (name). If you change your db so that the name field is required unique, and you do an insert inside a cftry/cfcatch block, that should work. Another option would be to query all the names in the db (before you do the insert), convert it to a valuelist, and then make sure that list does not contain form.name before doing the insert.
listONames=valuelist(myNameQuery.name); If (Not(ListFindNoCase(listONames,form.name))) ..... insert new name hth |
|
#5
|
|||
|
|||
|
This should really be handled by the database itself using a constraint. If you try to insert another record that duplicates one that is already in the database, it will throw a "unique contstraint violation" error, which you could catch and at that point you would know that there is already a record in the database.
But if you don't want to take that route, the only way to do it is to query the database, check that there aren't already duplicate records, and only then do the insert. |
|
#6
|
|||
|
|||
|
checking values
I did get that point checking in the database and throw an error.
Thanks guys for your valued tips and time. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > checking values in database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|