on 2010 Oct 31 9:08 PM
V12 has introduced the possibility to initialize local variables within the DECLARE statement, such as
declare lCnt integer = 0;
Now it would be fine if one could declare constants, too, (like "const int" in C/C++ etc.). This would be handy for longer blocks of code, e.g. to name savepoints or name expressions that are used in several queries.
And it might make explicit that a variable like in this question cannot be changed unintentionally...
I don't know if constants are defined in the SQL standards, so I won't suggest a particular syntax.
I like this idea and will discuss it with the SA development team for possible inclusion in a future release. Thanks for making the suggestion. As mentioned in Ivan's response to this question, the optimizer cannot use variable values when optimizing queries define within a stored procedure, but with the ability to mark a variable as constant (and if its value is, in fact, a constant) then there is the possibility that the optimizer could use the constant value at optimization time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
10 | |
10 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.