<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from (
                SELECT
                    t.employee_id,
                    t.employee_code,
                    t.employee_name name,
                    t.admin_flag
                FROM
                    exp_emp_user_a_v t) e #WHERE_CLAUSE#
                ORDER BY
                    employee_code
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    UPDATE
                        sys_user u
                    SET
                        u.admin_flag = ${@admin_flag}
                    WHERE
                        u.user_id =
                        (SELECT
                            v.user_id
                        FROM
                            exp_emp_user_a_v v
                        WHERE
                            v.employee_id = ${@employee_id}
                        );
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="admin_flag"/>
        <bm:field name="employee_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EMPLOYEE_ID"/>
        <bm:field name="employee_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EMPLOYEE_CODE" prompt="EXP_EMPLOYEES_VL.EMPLOYEE_CODE"/>
        <bm:field name="name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NAME" prompt="EXP_EMPLOYEES_VL.DESC"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="employee_code" queryExpression="employee_code like ${@employee_code}"/>
        <bm:query-field field="name" queryExpression="name like ${@name}"/>
    </bm:query-fields>
</bm:model>
