Use RAISERROR with International error messages?

  • Hi-

    I'd proposing that our team uses RAISERROR rhater than OUTPUT params within Stored Procedures.  For example, If the SProc should authenticate the user but the user does not exist, raise a 'User does not exist' error rather than setting an output param to, lets say 34, which may mean 'user does not exist'.

    But, since the system needs to be multi-lingual - the RAISERROR metholology was quickly dismissed.

    Please help - B

  • That (multi-lingual) is actually one of the stregnths of raiserror !

    Why are you saying that ?

     


    * Noel

  • Yes - I WANT to use RAISERROR and I believe it handles multi-languages.  I would like to prove the other assumptions wrong.

    If I use sp_addmessage - can I add multiple messages per language - or what is the recommended approach?

    - B

  • Ah, ussage is your promblem! this is how you are supposed to use it:

    at setup time call sp_addmessage for all required languages

    ex:

    use master

    exec sp_addmessage @msgnum = 50001, @severity = 10,  @msgtext = N'US English message',

       @lang = 'us_english'

    EXEC sp_addmessage @msgnum = 50001, @severity = 10,    @msgtext = N'Mensaje en Español',

       @lang = 'Español'

     

    immeadiately after the session is stablished

    execute this:

    set Language 'Español'

    then all your raiserror statements will be returned in spanish

    if instead you do

    set Language 'us_english'

    then all your raiserror statements will be returned in English

    make sure your numbers match and are greater or equal to 50000

     

    hth


    * Noel

  • Wow thanks.

    So, from a front end application, I would need to send the "Language String" to all Stored Procedures so wthy would know what language to use ?

    Procedure GetPerson(ID_Person int, LanguageToUse varchar(50))

    set Language = LanguageTouse --possibly 'us_english'

    Select BlahBlah from Person where ID_Person = @ID_Person.

    -------

    Is this somewhat correct?

    Regardless - thanks again very mucho!

  • No

    You call set Language ONCE at the begining of the session and that is it !

    any raiserror from that point on will return the messages on that language as long as you just invoke the number

    Again read my message carefully.

    1. Setup all necessary messages for all laguages

    2. Right After the connection is stablished execute a set language command

    3. Enjoy!

     


    * Noel

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply