Mysql function to return row count from a procedure call -
this question has answer here:
i trying write function return number of rows call stored procedure return. i'm trying minimise repetition of code (for reduced code maintenance/debugging- procedure select long).
the stored procedure read-only selects rows matching criteria (vague know details should not material question).
i copy procedure function , change select count() long multiple joins hoping write function call procedure , return row count. goal not optimised running efficient code maintenance, boiler plate reduction.
i have tried test:
delimiter // create procedure if not exists proc_select1() begin select 1; end // create function if not exists select1_count() returns int unsigned begin call proc_select1(); return found_rows(); end // delimiter ;
however when select select1_count();
- hoping return 1
- "cannot return result set function" error.
i tried assigning found_rows
variable, clearing result set returning variable value can't work.
does know work around or need copy-paste procedure , convert select count
, function?
i'm using mysql 5.5.16 (can upgrade if necessary), windows 7 (nobody seems want upgrade :) heidisqlv7.0.0.4053 (if relevant)
as always, appreciated.
first use distinct distinct values use count on that..like
select count(distinct column_name) table_name
Comments
Post a Comment