私は本当に単純なストアドプロシージャを追加するように開発者が依頼し続けているホストされたMySQLデータベースを持つクライアントを持っています。このようなストアドプロシージャを見ると、ストアドプロシージャとして実装され、アプリケーションコード内に実装されない理由は何もありません。これはストアドプロシージャの使用が本当に奇妙なものであることを訂正していますか?これはMySQLストアドプロシージャを論理的に使用していますか?
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;
http://www.pcpro.co.uk/blogs/2008/05/18/when-to-use-stored-procedures/ –