I would like to create a sp with the next code:
select *
from document
where cod_emp='AAA'
and cod_situation in ('01','02','03');
But I would like ('01','02','03') to be a parameter, so I thought something like this would work:
-- sp's call
call sp('"01","02","03"');
-- sp's parameter
in param_txt_cod_situation text;
-- sp's code
set @cons1=
'select *
from document
where cod_emp="AAA" ';
if length(param_txt_cod_situation)>0 then
set @param_txt_cod_situation=param_txt_cod_situation;
set @cons2='and cod_situacion in concat("(",?,")") '
else
set @param_txt_cod_situation=true;
set @cons2='and ?';
end if;
set @cons=concat(
@cons1,
@cons2);
prepare cons from @cons;
execute cons using
@param_txt_cod_situation;
deallocate prepare cons;
But it didn't work.
Hope you guys can help me. Thanks very much.