We use in all procedures customized error codes to give feedback to the client what was wrong.

// Initialized during Database generation
sp_addmessage 20102, 'Some Custom Error Message %1! only as an Example';
.... 
// In Procedures 
raiserror 20102, 'with a Parameter';

We have different users working with the same instance of the Database in different countries in Europe.

My first thought was to have a translation table an query with the error code against this table. But what about the parameters used ?

What is best practice ? Is it possible to avoid a second call to the database ?

Kind Regards Thomas

asked 02 Feb '10, 09:31

Thomas%20Duemesnil's gravatar image

Thomas Dueme...
2.7k293965
accept rate: 17%

edited 02 Feb '10, 11:57


You can choose the langauge for error messages with the dblang utility or the "SALANG" environment variable. But this setting only applies to "integrated" error messages. For custom errors, created with "create message" or "sp__addmessage" ( i can't find a sp_setmessage procedure even in the newest help for SA12) there is no possibility afaik to store different messages for different languages in SA (as, according to the help file, is available in ASE). We used our own table and function and the connection property "language", which is set through the aforementioned steps.

raiserror 2000009 dba.Lang_getMessages(2000009,connection_Property('language')),Zim(LfZimmer)
permanent link

answered 02 Feb '10, 11:05

Markus%20D%C3%BCtting's gravatar image

Markus Dütting
53641220
accept rate: 30%

edited 02 Feb '10, 17:31

sp_setmessage is as self written wrapper for sp_addmessage. Sorry for the confusion.

Do I understand correctly that you call dba.Lang_getMessages after you received an error as a separate statement? How do you handle Parameter in raiserror ?

(02 Feb '10, 11:54) Thomas Dueme...
1

No i dont call it afterwards, the result of the function is the error message for raiserror and you can use parameters as before ( "Zim(LfZimmer)" is another function which returns a string for the parameter "LfZimmer" and it's used in the error message %1!). The example is just one statement, which was wrapped.

(02 Feb '10, 13:01) Markus Dütting
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×23

question asked: 02 Feb '10, 09:31

question was seen: 2,651 times

last updated: 02 Feb '10, 17:31