From: Marco M. <mm...@ly...> - 2003-03-03 00:31:18
|
Hi, as far as I remember, exception with a message that can build "on the fly" in a trigger or a SP is available for FB 1.5 or planned. Thinking about what I actually need in my database, I think that a "customisable" message would be better, I mean, something like: EXP_WRONG_CODE = 'THE CODE %s IS WRONG, TRY AGAIN'; And in the SP EXCEPTION EXP_WRONG_CODE(CAST(NEW.ITEMCODE AS VARCHAR(10))); This is much better than having to assign all the message only to change a little but fundamental information. What do you think about it? Regards Marco Menardi |
From: Mike N. <ta...@al...> - 2003-03-03 02:26:46
|
I can't really comment on the utility of the proposal. I did however start to think about some technical aspects of it. Marco Menardi wrote: > EXP_WRONG_CODE = 'THE CODE %s IS WRONG, TRY AGAIN'; I'm not so sure about the syntax of parameter substitution here. There are (at least) two issues: 1. The user have to learn/use different specifiers depending on data type. 2. It makes localisation awkward, since the position would be fixed relative any other substitution needed in the same exception. What about "{1}", "{2}" ... "{n}"? That would handle the seond problem outlined above, allowing something like FOO='Hey {3}, you can't {1} record #{2}!', and at use EXCEPTION FOO('delete', old.rec_id, 'Mike') It would be only one type used for these substitution, string. Any type used in the substitution would have to have to be convertible to string. If someone really had the urge or need to cast data types back and forth (maybe to truncate incoming strings) I see no reason to disallow it, but for the general case such casts wouldn't have to be performed - it would know how to turn e.g. an integer into a string. Just some technical ideas on a subject I otherwise haven't even considered. /Mike |
From: Alex P. <pe...@in...> - 2003-03-03 09:42:24
|
> > What about "{1}", "{2}" ... "{n}"? That would handle the seond problem > outlined above, allowing something like FOO='Hey {3}, you can't {1} > record #{2}!', and at use > EXCEPTION FOO('delete', old.rec_id, 'Mike') > This syntax with string-only substitution sounds good for me. Must we enable exceptions like: FOO='Hey {3}, you can't {1} record #{3}!' Should we treat this as a bug or: 'Hey Mike, you can't delete record #Mike!' Should we require precise match for number of exception params and {n} in exception or may replace missing one with empty strings and ignore unneeded? Alex. |
From: Mike N. <ta...@al...> - 2003-03-03 17:48:04
|
Alex Peshkov wrote: > This syntax with string-only substitution sounds good for me. > Must we enable exceptions like: > FOO='Hey {3}, you can't {1} record #{3}!' > Should we treat this as a bug or: > 'Hey Mike, you can't delete record #Mike!' The latter. Even if perhaps a bit odd to not use parameter 2 in this example, I don't see why reusing parameters like this would be a problem. > Should we require precise match for number of exception params > and {n} in exception or may replace missing one with empty strings > and ignore unneeded? I think parameters that are requested in format string but not present at the point of use (i.e. the exception clause) should be allowed, at least we shouldn't SEGV. :-) What such missing parameter should be replaced with, I do not know. An empty string is one possibility, but perhaps the string "{missing exception parameter n}", where 'n' would be the parameter number expected, such as "{3}". I'd also expect that string to be hard-coded and not subject to localisation. What could pose another problem, maybe even more interesting, would be to give too many parameters. What should the outcome of that be? I believe it should do substitution as requested, but maybe display even the error? Something like: Hey nn, ... (the real message) Too many parameters to exception FOO from SP BARF. Expected 3 but got 6 parameters. param4: "Symphony of destruction" param5: "3.1415926535897932384626433832795" param6: "80:4711" The "from SP BARF" might or might not be a good thing to have, to help in tracking down such offenders. But this is still all an academic discussion, right? :-) /Mike |
From: Alex P. <pe...@in...> - 2003-03-03 18:00:08
|
> > But this is still all an academic discussion, right? :-) > > /Mike > I think that this is discussion concerning 2.0 :) Alex. |
From: Nickolay S. <sk...@bs...> - 2003-03-03 18:10:02
|
>> >> But this is still all an academic discussion, right? :-) >> >> /Mike >> > I think that this is discussion concerning 2.0 :) I think it is still possible to bribe Dmitry to implement this feature in 1.5. ;)) Mike, if you really need this feature - it is small and is really easy to implement. It can sneak to FB1.5 during beta stage I think... > Alex. Nickolay Samofatov |
From: Dmitry Y. <di...@us...> - 2003-03-03 18:23:19
|
Nickolay, > > I think that this is discussion concerning 2.0 :) > > I think it is still possible to bribe Dmitry to implement this > feature in 1.5. ;)) Sorry, but it's not problem for Dmitry to just write small SP in his databases to handle parameters in exception messages ;-) Dmitry |
From: Marco M. <mm...@ly...> - 2003-03-03 21:50:58
|
What kind of 'magic' are you telling about? I know how to raise an exception, but not how change the message in a SP... I think that ofter a more precise (informative) exception message is welcome, but we must take care to avoid: a) exception definition proliferation, i.e. you end up with 1,000 different exception just to be more informative b) "build on the fly" exception, where you end up with only one exception, and build it's message "as needed". My suggestion is to create something like "exception families", or "cutomizable exception", so for invalid date you can have EXP_INVALID_QUANTITY = 'THE QUANTITY {1} IN {2} IS TOO SMALL, MINIMUM {3}'; and in some trigger, have: IF (NEW.BEER_QT < 100) THEN EXCEPTION EXP_INVALID_QUANTITY(NEW.BEER_QT, 'beer', '100'); IF (NEW.FIREBIRD_ORDERS_QT < 5000) THEN EXCEPTION EXP_INVALID_QUANTITY(NEW.FIREBIRD_ORDERS_QT, 'Firebird servers', '5,000'); regards Marco Menardi Dmitry Yemanov wrote: > Nickolay, > > >>>I think that this is discussion concerning 2.0 :) >> >>I think it is still possible to bribe Dmitry to implement this >>feature in 1.5. ;)) > > > Sorry, but it's not problem for Dmitry to just write small SP in his > databases to handle parameters in exception messages ;-) > > > Dmitry > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Firebird-devel mailing list > Fir...@li... > https://lists.sourceforge.net/lists/listinfo/firebird-devel > |
From: Mike N. <ta...@al...> - 2003-03-03 19:28:38
|
Nickolay Samofatov wrote: > I think it is still possible to bribe Dmitry to implement this > feature in 1.5. ;)) I don't think it should even be considered for 1.5, especially not this late in the beta-stages. Shouldn't we have been at feature-freeze quite some time ago? > Mike, if you really need this feature _I_ don't need it. I'm not even sure I'd want it! :-) It was someone else that suggested the %s syntax. I just commented on some of the technical aspects, possible problems and possible solution(s) of such parameterized string substitution. /Mike |