Reputation: 1771
I am creating a function that contains the following loop:
While v_start >= v_stop do
set v_msg := concat(v_msg,v_start,v_delimiter);
set v_start := v_start + v_step;
end while;
When I call the function, I pass the following parameter:
select a06_counter_loop(10,-5, -3, '-->') as 'The Loop Output';
It should return:
10-->7-->4-->1-->-2-->-5
But it returned:
10-->7-->4-->1-->-2-->-5-->
My question is that how do I get rid of the last non-number character?
Let me know if you need the entire code for the function.
Thanks, Perri
Upvotes: 0
Views: 38
Reputation: 204746
set v_msg := v_start; set v_start := v_start + v_step; While v_start >= v_stop do set v_msg := concat(v_msg,v_delimiter, v_start); set v_start := v_start + v_step; end while;
Upvotes: 1
Reputation: 64466
Try this by using CONCAT_WS(separator,str1,str2,...)
While v_start >= v_stop do
set v_msg := CONCAT_WS(v_delimiter,v_msg,v_start);
set v_start := v_start + v_step;
end while;
Upvotes: 1