What kind of Errors the SELECT statement can raise??
-
What kind of Errors the SELECT statement can raise?? In what cases? How to avoid them? How to handle them? ------------------------------------ To study, study and only to study
_J_ wrote: What kind of Errors the SELECT statement can raise?? That's kind of like asking "What kind of accidents can my car be involved in?" _J_ wrote: In what cases? When something goes wrong or not specified correctly. _J_ wrote: How to avoid them? Get your permissions sorted out. Don't refer to things that don't exist. Get the syntax right. _J_ wrote: How to handle them? DECLARE @error_number SELECT .... -- Your select statement goes here SET @error_number = @@ERROR -- @@ERROR is very short lived, grab it while you can. IF @error_number = ... -- You can find the error numbers and the errors they relate to in the sysmessages table If you can be more specific then perhaps I can give you a more specific response. There are somewhere in the region of 3900 error / warning messages in SQL Server.
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
_J_ wrote: What kind of Errors the SELECT statement can raise?? That's kind of like asking "What kind of accidents can my car be involved in?" _J_ wrote: In what cases? When something goes wrong or not specified correctly. _J_ wrote: How to avoid them? Get your permissions sorted out. Don't refer to things that don't exist. Get the syntax right. _J_ wrote: How to handle them? DECLARE @error_number SELECT .... -- Your select statement goes here SET @error_number = @@ERROR -- @@ERROR is very short lived, grab it while you can. IF @error_number = ... -- You can find the error numbers and the errors they relate to in the sysmessages table If you can be more specific then perhaps I can give you a more specific response. There are somewhere in the region of 3900 error / warning messages in SQL Server.
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
Ok. If i perform INSERT INTO ..... the most common error is cannot insert duplicate. However if i perform the SELECT and all parameters in my SELECT statement are ok, i.e. no syntax error and also all columns and tables that i specifyed are exist. So is the posibility of some kind of an error that can occur??? ------------------------------------ To study, study and only to study
-
Ok. If i perform INSERT INTO ..... the most common error is cannot insert duplicate. However if i perform the SELECT and all parameters in my SELECT statement are ok, i.e. no syntax error and also all columns and tables that i specifyed are exist. So is the posibility of some kind of an error that can occur??? ------------------------------------ To study, study and only to study
_J_ wrote: So is the posibility of some kind of an error that can occur??? Yes. Lots of errors may still occur. Permissions errors, disk space may run out, deadlocking, lots of things.
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
_J_ wrote: So is the posibility of some kind of an error that can occur??? Yes. Lots of errors may still occur. Permissions errors, disk space may run out, deadlocking, lots of things.
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
So as i understand: SELECT ..., ...., .... ... FROM .... ..... .... SELECT @myERROR = @@ERROR IF @myERROR != 0 here i handle the error, maybe call to RAISEERROR ------------------------------------ To study, study and only to study
IF @myERROR <> 0 The error will have already have generated a RAISERROR, but you can raise another if you like. It is rather like throwing an exception from within a catch block in C#.
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
IF @myERROR <> 0 The error will have already have generated a RAISERROR, but you can raise another if you like. It is rather like throwing an exception from within a catch block in C#.
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
I know that errors with severiry less than 10 is an information error(message) so in the C# i can't catch it in the try/catch/finally block, caues of that i will need to raise my error with severity > 10, after this i will catch this error in my application ------------------------------------ To study, study and only to study
-
I know that errors with severiry less than 10 is an information error(message) so in the C# i can't catch it in the try/catch/finally block, caues of that i will need to raise my error with severity > 10, after this i will catch this error in my application ------------------------------------ To study, study and only to study
Sounds reasonable to me. Alternatively you could write the Stored Procedure to exit at that point with the error number as a return code.
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
Sounds reasonable to me. Alternatively you could write the Stored Procedure to exit at that point with the error number as a return code.
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
What kind of Errors the SELECT statement can raise?? In what cases? How to avoid them? How to handle them? ------------------------------------ To study, study and only to study
Most of the SQL errors are non-recoverable unless you are writing code to design SQL statements. If you commonly get SQL errors then it is a sign that your application isn't using the SQL server properly. For example if you are adding a username/password to a registration database and the username must be unique, you should send a statement that returns different results based on a transacted exist/insert statement rather then trap the exception. Common occurances shouldn't typically appear in error handling or catch blocks.
I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon