Exceptions checking

Ivan Smahin ivan_smahin at paradigmasoft.com
Fri Sep 12 07:02:54 CDT 2008


Hello Bart,

Friday, September 12, 2008, 1:57:55 PM, you wrote:

>>
>>> EXCEPTION
>>>     WHEN ERR_CONSTRAINT_UNIQUE_VIOLATION THEN
>>>         return  ERR_CONSTRAINT_UNIQUE_VIOLATION
>>> END;
>>
>> Look, you are catching the exception and going to pass it outside.
>> Probably you should just let it go self? In this case client will get
>> an exception as usual.
>>
>> -- 


Another thing I forgot to say regarding "user" states.

You can do following:
RAISE 50001, 'Some user error';

So client will get an exception of type xUserError
with state == 50001 and message == 'Some user error'


Speaking of user-defined states...


Why do you think that XML is a best way for now?
Currently there is no option in Valentina to work with XML inside SP.
Well, I think it could be something like this:

1. Any user connecting to the server call some procedure which set
the preferable language ( @language variable )

2. Keep the possible states in some table

3. Keep the messages on different languages in another tables linked
to their state codes.

4. When you raise an exception you just select appropriate message
for current user.

The main idea is: all business logic is placed in the database.
No need in some additional manipulations getting something from the
database.


> Well no I think:

> Look what we need to do is have error.xml files for all our interface
> languages (for the moment three)
> So I need to have in case of an exception inside my procedure THAT
> ENDS THE PROCEDURE (let's say a duplicate in a unique) I would like to
> return to PHP the errorcode
> Then PHP can decide based on the clients language wat error message  
> will be displayed (english, dutch or french).

> Therefore I think we need our 3 edited (for language) own copies of  
> error.xml  inside our language specific directories.

> So when php calls a stored procedure I can have a fallback like this

> EXCEPTION
>         WHEN OTHERS THEN
>                 return @@LastErrorCode
> END;

> Then php can pick up the errorcode and proces for the appropriate  
> language.

> Will this work ?

Yes, it should work.

Generally speaking we can do something like this:
(It's only my vision)

1. There are 3 sources of states - sql_errors.xml, kernel_errors.xml,
userdefined_errors.xml

2. userdefined_errors.xml consist of single <GROUP name="User-defined
errors">  element. SQLSTATEs could be in 0x50000 - 0x59999 range

3. It could be English, German and so on clones placed in
vResources/English, vResources/German ...

4. We use connection property "Language" to determine which language
is preferable for the current user (Default is English). And prepare
the message using appropriate xml clone.

What do you think?

-- 
Best regards,
Ivan Smahin 
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com



More information about the Valentina mailing list