Click here to Skip to main content
15,888,351 members
Home / Discussions / Database
   

Database

 
AnswerRe: Best way to get PK value of newly created record Pin
Luc Pattyn13-Mar-12 5:48
sitebuilderLuc Pattyn13-Mar-12 5:48 
GeneralRe: Best way to get PK value of newly created record Pin
Shameel13-Mar-12 6:09
professionalShameel13-Mar-12 6:09 
AnswerRe: Best way to get PK value of newly created record Pin
PIEBALDconsult13-Mar-12 14:07
mvePIEBALDconsult13-Mar-12 14:07 
GeneralRe: Best way to get PK value of newly created record Pin
Shameel13-Mar-12 19:33
professionalShameel13-Mar-12 19:33 
GeneralRe: Best way to get PK value of newly created record Pin
PIEBALDconsult14-Mar-12 3:11
mvePIEBALDconsult14-Mar-12 3:11 
GeneralRe: Best way to get PK value of newly created record Pin
jschell14-Mar-12 8:50
jschell14-Mar-12 8:50 
AnswerRe: Best way to get PK value of newly created record Pin
Mycroft Holmes13-Mar-12 19:52
professionalMycroft Holmes13-Mar-12 19:52 
AnswerRe: Best way to get PK value of newly created record Pin
Bernhard Hiller13-Mar-12 21:53
Bernhard Hiller13-Mar-12 21:53 
First of all, separate the serial number and the primary key. If you use a Guid as the key, you can "calculate" it (Guid.NewGuid()) already on the client. In case of an autoincrement value, you can query it from the database with a SELECT @@ID.
Your serial number column should still have a unique index.
When you insert your data, omit the serial number first.
You can take two different approaches here:
(1) Create a trigger. In the trigger function, calculate your serial number. Take care that two calculations may happen at the same time in different threads. The trigger function then updates your data. Retrieve the inserted serial number with a select query.
(2) Calculate the serial number on the client. Do an update query. When the update fails due to a duplicate value, calculate again with adjusted parameters, and try again, till the update does not fail. Here, I'd use a transaction, and commit when the update was succesful. Looks bad, but with a low chance of duplicates, it will not cause bad performance.
Question1045 - Access denied for user "root@192.168.1.9" using password: YES Pin
Jassim Rahma12-Mar-12 20:12
Jassim Rahma12-Mar-12 20:12 
AnswerRe: 1045 - Access denied for user "root@192.168.1.9" using password: YES Pin
Wayne Gaylard12-Mar-12 20:42
professionalWayne Gaylard12-Mar-12 20:42 
AnswerRe: 1045 - Access denied for user "root@192.168.1.9" using password: YES Pin
Gerben Jongerius12-Mar-12 23:36
Gerben Jongerius12-Mar-12 23:36 
GeneralRe: 1045 - Access denied for user "root@192.168.1.9" using password: YES Pin
Jassim Rahma13-Mar-12 0:17
Jassim Rahma13-Mar-12 0:17 
GeneralRe: 1045 - Access denied for user "root@192.168.1.9" using password: YES Pin
Gerben Jongerius13-Mar-12 0:22
Gerben Jongerius13-Mar-12 0:22 
GeneralRe: 1045 - Access denied for user "root@192.168.1.9" using password: YES Pin
Jassim Rahma13-Mar-12 1:53
Jassim Rahma13-Mar-12 1:53 
GeneralRe: 1045 - Access denied for user "root@192.168.1.9" using password: YES Pin
Jassim Rahma13-Mar-12 7:16
Jassim Rahma13-Mar-12 7:16 
GeneralRe: 1045 - Access denied for user "root@192.168.1.9" using password: YES Pin
Gerben Jongerius13-Mar-12 22:18
Gerben Jongerius13-Mar-12 22:18 
GeneralRe: 1045 - Access denied for user "root@192.168.1.9" using password: YES Pin
Jassim Rahma14-Mar-12 2:47
Jassim Rahma14-Mar-12 2:47 
Questionhelp me! Pin
anushh12-Mar-12 20:05
anushh12-Mar-12 20:05 
AnswerRe: help me! Pin
Prasad_Kulkarni12-Mar-12 20:25
Prasad_Kulkarni12-Mar-12 20:25 
GeneralRe: help me! Pin
anushh12-Mar-12 20:36
anushh12-Mar-12 20:36 
GeneralRe: help me! Pin
Prasad_Kulkarni12-Mar-12 22:38
Prasad_Kulkarni12-Mar-12 22:38 
QuestionJoining fields from several tables onto one SSRS report Pin
SQL Ed12-Mar-12 4:30
SQL Ed12-Mar-12 4:30 
AnswerRe: Joining fields from several tables onto one SSRS report Pin
Mycroft Holmes12-Mar-12 22:17
professionalMycroft Holmes12-Mar-12 22:17 
GeneralRe: Joining fields from several tables onto one SSRS report Pin
SQL Ed13-Mar-12 0:06
SQL Ed13-Mar-12 0:06 
GeneralRe: Joining fields from several tables onto one SSRS report Pin
Mycroft Holmes13-Mar-12 0:37
professionalMycroft Holmes13-Mar-12 0:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.