I have a client with a hosted MySQL database whose developer keeps asking me to add really simple stored procedures. I look at a stored procedure like this, and I don't see any reason why it would be implemented as a stored procedure and not implemented within application code. Am I correct that this is really strange use of stored procedures?
CREATE DEFINER = 'username'@'%' PROCEDURE `sp_get_payrollgl`(IN pi_glcode TEXT)
DETERMINISTIC
CONTAINS SQL
SQL SECURITY INVOKER
COMMENT ''
BEGIN
if (pi_glcode is null || pi_glcode = '') then
select glcode,descr,
case when crdb = 1 then 'CR' else 'DB' end as 'crdb',
case when taxable = 1 then 'Yes' else 'No' end as 'taxable',
case when billable = 1 then 'Yes' else 'No' end as 'billable',
case when active = 1 then 'Yes' else 'No' end as 'active'
from payrollgl;
else
select glcode,descr,
case when crdb = 1 then 'CR' else 'DB' end as 'crdb',
case when taxable = 1 then 'Yes' else 'No' end as 'taxable',
case when billable = 1 then 'Yes' else 'No' end as 'billable',
case when active = 1 then 'Yes' else 'No' end as 'active'
from payrollgl where glcode = pi_glcode;
end if;
END;