|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
want to insert info but running into errors about PK
ok guys as you probably have noticed I am new to coldfusion and running into all kinds of fun problems. I have a form that fills out a DB and later an approver has the ability to change the pk in case they need two of the same requests they can change the pk to one number difference but is there a way that I can have something in coldfusion search the DB and if that PK is already in the DB once they hit the submit button than an error pops up telling them they have to use a different number convention b/c that one is already being used? Kind of like a validation. right now if i enter two of the same number it just goes to the blue coldfusion error page and tells me:Violation of PRIMARY KEY constraint 'PK_Vacancy_Approved'. Cannot insert duplicate key in object 'Vacancy_Approved'.
instead of telling me to rename??? any ideas? |
|
#2
|
|||
|
|||
|
You can't insert two records with the same primary key, no matter what. And you should never change the primary key either. In fact, you should have CF or the database assign the primary key, never the user.
However, you could use a cftry/cfcatch block to catch the database error and do something else, or show a nicer error to the user.
__________________
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
|
|||
|
|||
|
Yea kiteless I need something like that. Well see the pk is derived from 3 fields on a different table in a specific format. I only allow the approver to login and change the number if he needs to forwhatever reason. At the least I need something that displays a nice error. I will look into the cftry and cfblock and see how they can be used. Do you have any good site examples/tutorials that I could look at or any code that might be helpful? Thanks.
|
|
#4
|
|||
|
|||
|
The documentation is always a good place to start.
http://livedocs.macromedia.com/cold...8.htm#wp1104557 |
|
#5
|
|||
|
|||
|
trouble...still...never not in trouble...
ok I understand whats going on but applying it to my actual circumstance is what is getting me. I have a PK column which is idnum, i want to have it so that if the approver trys to submit the same form twice that it will tell them they can't do that, and try to do that w/ out the coldfusion blue error box popping up below it. I know there is probably very easy ways to do this but I am not running into them...Hellllpp!!!
|
|
#6
|
|||
|
|||
|
The documentation link above has an example of catching a database error. Within the cfcatch block, you can output a friendly error message, or do a cflocation back to the form page and explain to them that they can't insert the same record twice.
|
|
#7
|
|||
|
|||
|
cf
ahh yes, i see now i see. Well I am gonna do some reading over the weekend. I do like coldfusion, just a matter of learning the tags and how to use them. have a good one thanks for your help.
jack |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > want to insert info but running into errors about PK |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|