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

Database

 
GeneralRe: Conditional SQL commands: Good? Bad? Pin
Mycroft Holmes27-Jan-14 20:57
professionalMycroft Holmes27-Jan-14 20:57 
GeneralRe: Conditional SQL commands: Good? Bad? Pin
Kornfeld Eliyahu Peter27-Jan-14 21:02
professionalKornfeld Eliyahu Peter27-Jan-14 21:02 
GeneralRe: Conditional SQL commands: Good? Bad? Pin
Mycroft Holmes27-Jan-14 21:06
professionalMycroft Holmes27-Jan-14 21:06 
GeneralRe: Conditional SQL commands: Good? Bad? Pin
Kornfeld Eliyahu Peter28-Jan-14 23:28
professionalKornfeld Eliyahu Peter28-Jan-14 23:28 
GeneralRe: Conditional SQL commands: Good? Bad? Pin
Jörgen Andersson27-Jan-14 23:10
professionalJörgen Andersson27-Jan-14 23:10 
GeneralRe: Conditional SQL commands: Good? Bad? Pin
Richard Deeming28-Jan-14 1:34
mveRichard Deeming28-Jan-14 1:34 
GeneralRe: Conditional SQL commands: Good? Bad? Pin
Jörgen Andersson28-Jan-14 2:32
professionalJörgen Andersson28-Jan-14 2:32 
AnswerRe: Conditional SQL commands: Good? Bad? Pin
Shameel27-Jan-14 22:39
professionalShameel27-Jan-14 22:39 
It is always better to put all the database code on the database side. An equivalent application code for the above query will make atleast three database calls as opposed to one call when the IF is on the database side.

There could be a race condition with you query and the possibility of a row being inserted by another user between the IF and the INSERT, so you should actually handle the exception and take appropriate action (either let the user know that someone else has already inserted it or do an update). The possibility is even higher in case of application code because of network latency between the server and the client.

And your UPDATE statement is missing the WHERE clause and it would end up updating all the rows in the table Smile | :)
AnswerRe: Conditional SQL commands: Good? Bad? Pin
jschell28-Jan-14 10:40
jschell28-Jan-14 10:40 
QuestionDatabase Design Tools? Pin
Code_Crash26-Jan-14 21:41
Code_Crash26-Jan-14 21:41 
AnswerRe: Database Design Tools? Pin
Richard MacCutchan26-Jan-14 21:58
mveRichard MacCutchan26-Jan-14 21:58 
AnswerRe: Database Design Tools? Pin
Jörgen Andersson27-Jan-14 1:36
professionalJörgen Andersson27-Jan-14 1:36 
GeneralRe: Database Design Tools? Pin
Code_Crash27-Jan-14 2:27
Code_Crash27-Jan-14 2:27 
AnswerRe: Database Design Tools? Pin
thatraja27-Jan-14 2:15
professionalthatraja27-Jan-14 2:15 
GeneralRe: Database Design Tools? Pin
Code_Crash27-Jan-14 2:31
Code_Crash27-Jan-14 2:31 
QuestionEntity framework Pin
columbos1492725-Jan-14 7:58
columbos1492725-Jan-14 7:58 
AnswerRe: Entity framework Pin
jschell25-Jan-14 13:01
jschell25-Jan-14 13:01 
AnswerRe: Entity framework Pin
S Douglas26-Feb-14 10:28
professionalS Douglas26-Feb-14 10:28 
GeneralMessage Closed Pin
25-Jan-14 3:18
anilkg2y25-Jan-14 3:18 
GeneralMessage Removed Pin
25-Jan-14 13:01
jschell25-Jan-14 13:01 
GeneralMessage Removed Pin
25-Jan-14 21:21
mveRichard MacCutchan25-Jan-14 21:21 
GeneralMessage Removed Pin
27-Jan-14 3:18
professionalShameel27-Jan-14 3:18 
Questionsql/PLSQL :need a expert help on this Pin
ramina sen23-Jan-14 6:38
ramina sen23-Jan-14 6:38 
QuestionRe: sql/PLSQL :need a expert help on this Pin
Eddy Vluggen23-Jan-14 7:55
professionalEddy Vluggen23-Jan-14 7:55 
QuestionSSRS - No of Rows per page Pin
berba22-Jan-14 19:50
berba22-Jan-14 19:50 

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.