sql - Passing an integer array to mysql procedure -
i want create stored procedure receives array of integers , other input, example:
create procedure test (field1 varchar(4), field2 varchar(4), array varchar (255))
and in stored procedure want use this:
... some_field in (array) ...
the problem in way getting rows correspondence first integer in array.
is there way make work (i tried use find_in_set
did same in
)?
the call making testing stored procedure call test (12, 13, '1, 2, 3')
.
find_in_set() works, can't have spaces in string of numbers.
demo:
mysql> select find_in_set(2, '1, 2, 3'); +---------------------------+ | find_in_set(2, '1, 2, 3') | +---------------------------+ | 0 | +---------------------------+ mysql> select find_in_set(2, '1,2,3'); +-------------------------+ | find_in_set(2, '1,2,3') | +-------------------------+ | 2 | +-------------------------+
so should either form list no spaces before pass procedure, or else in procedure, use replace() strip out spaces.
Comments
Post a Comment