나는 정말로 간단한 저장 프로 시저를 추가하도록 개발자가 계속 요청하는 호스팅 된 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/ –