The brand new MySQL recursive ask stored process engineering
An element of the block and DoubleVal techniques get a hold of a couple different copies away from num as DoubleVal eter
We will very first focus on SP_parse_integer as the head step goes here. Line , of information method of BIGINT. Whenever a titled MySQL kept techniques transform the value of a keen INOUT parameter, the fresh contacting MySQL recursive query stored techniques can see those transform. Consequently, a keen INOUT parameter works a lot like a-c# Ref parameter, an excellent ByRef parameter, a c++ resource factor, etcetera. In all this type of instances, i citation parameter addresses one to jobs as the recommendations with the factor viewpoints. The fresh contacting and you can named actions, characteristics, held strategies, etcetera. the understand the same worthy of inside the memory, which, all of them come across all changes that happens to people philosophy. Conversely, an admiration factor limits the brand new visibility of its alter on techniques otherwise mode where those alter happen.
Part of the code take off announces adjustable num and you can establishes it so you’re able to 5. In the primary block, step one phone calls the method DoubleVal, and you can entry disagreement num, having its value of 5. The DoubleVal procedure gets the num well worth as its own regional duplicate of your own brand-new num value, based in the Chief cut-off. During the DoubleVal, step two change one regional num worthy of in order to 10, and control production back again to the main block. A portion of the take off never ever observes one to change, but this method would avoid the SP_parse_integer MySQL recursive inquire regarding functioning. Within step three, it images the benefits which notices for the num – in cases like this, 5. This cut off shows a comparable code attempt, but brand new DoubleVal process eter:
That it cut off spends a ByVal parameter to display exactly how a respect parameter work:
3 outputs 10 because the both Main cut off in addition to DoubleVal process operate into exact same num value in thoughts. The fresh SP_parse_integer MySQL recursive inquire use this technique. DoubleVal eter. In that way, both Main take off and DoubleVal comprehend the same well worth inside memories, at the same thoughts area. This means that, if DoubleVal procedure changed the worth of num into the action dos, one changes became noticeable to the main block on step three. These types of info expand to many other invention languages and you may tools, together with MySQL. Having a great MySQL recursive ask, an INOUT held techniques factor will get the equivalent of an artwork Earliest ByRef parameter. The fresh new technology about the newest MySQL stored steps appeared in this post hinges on INOUT variables.
Observe that MySQL offers Inside the variables, hence services like the Graphic Very first ByVal details described above. MySQL offers Out variables. An entitled MySQL held process that “receives” an away factor can’t comprehend the first, or performing, the worth of an out parameter that contacting kept techniques kits for that e-chat-ondersteuning factor.
Today we are able to focus on the SP_parse_integer held process because an effective MySQL recursive inquire. Given that seen significantly more than, lines 5 so that as INOUT details. The fresh param parameter retains the brand new integer so you’re able to parse, and you will parse_string_param usually hold the put together string that the kept process have a tendency to create. Range 10 announces a region BIGINT varying SP_role, that secure the individual multiple-of-a couple of thinking that stored process parses from the param worthy of. It MySQL recursive inquire output NULL to have param philosophy less than step one otherwise more than 1999998, toward When the-cut-off off lines 12 so you can 14. The ELSEIF stop regarding contours sixteen to 19 becomes this new recursion feet case. When param is at zero, new held processes completed extracting several-of-two beliefs away from param in itself. Line sixteen examination because of it, just in case correct, traces 18 and you can 19 remove the behind comma and you can space (, ) out-of parse_string_param. Upcoming, they put an ending proper parenthesis. For this stored procedure, we will disregard the boundary case if this productivity blank parentheses in the event the we call-it which have an excellent param value of no (0).
댓글을 남겨주세요
Want to join the discussion?Feel free to contribute!