ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old August 5th, 2004, 03:38 PM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
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?

Reply With Quote
  #2  
Old August 5th, 2004, 03:51 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
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

Reply With Quote
  #3  
Old August 6th, 2004, 08:06 AM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
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.

Reply With Quote
  #4  
Old August 6th, 2004, 08:27 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
The documentation is always a good place to start.

http://livedocs.macromedia.com/cold...8.htm#wp1104557

Reply With Quote
  #5  
Old August 6th, 2004, 11:58 AM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 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!!!

Reply With Quote
  #6  
Old August 6th, 2004, 12:56 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
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.

Reply With Quote
  #7  
Old August 6th, 2004, 02:13 PM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > want to insert info but running into errors about PK


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway