Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dohamsg
Starting Member
22 Posts |
Posted - 2008-09-23 : 10:03:28
|
| MSSQL2005, Delphi2007.Hi,If the user forgets to input Employee Name, and tries to post the data, I don't want the database engine to raise the error <column Name doesn't accept Null Value>, instead I'd like to popup afriendly message like <Please enter an employee Name> and set input focus to the EmployeeName edit box from within Delphi.I have written a stored procedure that does the error checking before posting the data, the problem I'm facing is that I can't localize messages inside stored procedure (English, French, Spanish...) since message texts are compiled inside the stored procedure.I tried to map return values to messages, for example if returnValue = 0 <no error>, if = -1 <Duplicate Name>, if = -2 <EmployeeName is empty>...This way from Delphi after catching the returnValue I popup a friendly localized message to the user; but no way, since a stored procedure can call another stored procedure and if returnValue = -2, I don't know which stored procedure returned that value!I decided to move error checking from Stored Procedure to Delphi, if everything is OK, I call the stored procedure to post data.Is this a good practice ?I welcome any suggestion.Many Thanks. |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-09-23 : 10:33:27
|
| You should be sure to maintain data integrity with appropriate constraints within the database. After all your current application will likely not be the only access to the data.One common method is to use a combination of sql server errors and custom errors to communicate with calling applications. The application can CATCH these errors and THROW localized versions as needed.I personally only use non-zero Return Codes to communicate between SP calls and typically simply rely on zero vs. non-zero return codes to determine success vs. failure by the calling application. I rely on errors raised to know the reason for any failures.Be One with the OptimizerTG |
 |
|
|
dohamsg
Starting Member
22 Posts |
Posted - 2008-09-23 : 11:46:15
|
| I think I found a solution:I add an extra parameter to the stored procedure let's say @ErrorMessage NVARCHAR(1000) OUTPUTand from the Client Application I compare @ErrorMessage to a set of messages dealing with specific entity (table) hard coded in the stored procedures that were called.Thanks to God then to TG. |
 |
|
|
|
|
|
|
|