Insert new entity when primary key is varchar

Posts   
 
    
bigpaul
User
Posts: 3
Joined: 21-Apr-2006
# Posted on: 21-Apr-2006 07:16:21   

Quick Question. I have a table which has a primary key being varchar(10). Is there a way to check for duplicate PK before inserting in generated code or I have to check that manually?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Apr-2006 08:11:53   

Regardless of the type, you have to check it manually.

Or you may try to insert with a try catch block this will save you a visit to the database if the key was new, thus the Insert will suceed in one shot.

bigpaul
User
Posts: 3
Joined: 21-Apr-2006
# Posted on: 21-Apr-2006 08:23:34   

Walaa wrote:

Regardless of the type, you have to check it manually.

Or you may try to insert with a try catch block this will save you a visit to the database if the key was new, thus the Insert will suceed in one shot.

Thanks for the reply. That would work.