PLSQL程序规范代码对齐规范使用良好的对齐规范,可以明显的增强程序的可读性、以及程序的美观程度,同时可以减少程序出错的概率,增强可维护性。总体来说,对齐要基于程序层次情况,使用首尾对齐原则,如下例所示:

FUNCTION GET_EMPLOYEE_SALARY(P_EMPLOYEE_ID NUMBER, P_MONTH NUMBER) RETURN NUMBER IS
    V_SALARY NUMBER;
    CURSOR CUR_EMPLOYEE_PAYROLL_ELEMENT IS
        SELECT payroll_element_code, base_salary
        FROM ps_payroll_elements ppe
        WHERE ppe.EMPLOYEE_id = p_EMPLOYEE_id
        AND ppe.payment_month = p_month;
BEGIN
    V_SALARY := 0;
    FOR C1 IN CUR_EMPLOYEE_PAYROLL_ELEMENT LOOP
        IF C1.base_salary IS NOT NULL THEN
            V_SALARY := V_SALARY + C1.base_salary;
        END IF;
    END LOOP;
    RETURN V_SALARY;
END GET_EMPLOYEE_SALARY;