Stored Prc and System Variable

You can use the information_schema;

select VARIABLE_VALUE INTO @v FROM information_schema.GLOBAL_STATUS WHERE VARIABLE_NAME='prepared_stmt_count';

This does a user variable, however other stored procedure vars should be possible.


  1. prepapred_stmt_count returns the total number or prepared statements in use. Does your applications really need to keep 27782 statements in open state? If a statement will not be used it should be closed immediately to free resources.
  1. It doesn't make sense to write a stored procedure for getting this value when you can use a simple select:

SELECT VARIABLE_VALUE from INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME="prepared_stmt_count"

or if you want to store the value in a user variable

SELECT @p_out:= VARIABLE_VALUE ..