<?xml version="1.0" encoding="UTF-8"?>
<ns1:model xmlns:ns1="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1">
    <ns1:operations>
        <ns1:operation name="insert">
            <ns1:update-sql><![CDATA[
    			begin
    				fnd_dimension_values_pkg.insert_fnd_company_dim_values(p_company_id           =>${/session/@company_id},
								                                           p_dimension_code       =>${@dimension_code},
								                                           p_dimension_value_code =>${@dimension_value_code},
								                                           p_description          =>${@dimension_value_description},
								                                           p_summary_flag         =>${@summary_flag},
								                                           p_enabled_flag         =>${@enabled_flag},
								                                           p_created_by           =>${/session/@user_id},
								                                           p_dimension_value_id   =>${@dimension_value_id});
    			end;
    		]]></ns1:update-sql>
            <ns1:parameters>
                <ns1:parameter name="dimension_value_id" input="false" output="true" outputPath="@dimension_value_id"/>
            </ns1:parameters>
        </ns1:operation>
        <ns1:operation name="update">
            <ns1:update-sql><![CDATA[
        		begin
        			fnd_dimension_values_pkg.update_fnd_company_dim_values(p_dimension_value_id =>${@dimension_value_id},
								                                           p_company_id         =>${/session/@company_id},
								                                           p_enabled_flag       =>${@enabled_flag},
								                                           p_last_updated_by    =>${/session/@user_id},
								                                           p_description        =>${@dimension_value_description});
        		end;
        	]]></ns1:update-sql>
        </ns1:operation>
        <ns1:operation name="query">
            <ns1:query-sql><![CDATA[
        		select *
				    from (  
				             
				             
				       SELECT FV.DIMENSION_ID,
				              FV.DIMENSION_VALUE_CODE,
				              FV.DESCRIPTION DIMENSION_VALUE_DESCRIPTION,
				              FV.DIMENSION_VALUE_ID,
				              FS.DIMENSION_CODE,
				              FV.SUMMARY_FLAG,
				              fcdv.ENABLED_FLAG ENABLED_FLAG,
				              FS.DESCRIPTION
				         FROM FND_DIMENSION_VALUES_VL FV, FND_DIMENSIONS_VL FS,fnd_company_dimension_values  fcdv
				        WHERE FV.dimension_id = FS.dimension_id
				        and   fcdv.company_id=${/session/@company_id}
				        and  fcdv.dimension_value_id=fv.dimension_value_id 
				           
				    ) v
			
				#WHERE_CLAUSE#ORDER BY V.DIMENSION_VALUE_CODE
        	]]></ns1:query-sql>
        </ns1:operation>
    </ns1:operations>
    <ns1:query-fields>
        <ns1:query-field name="dimension_code" dataType="java.lang.String" queryExpression="v.DIMENSION_CODE = ${@dimension_code}"/>
        <ns1:query-field name="dimension_value_code" dataType="java.lang.String" queryExpression="v.DIMENSION_VALUE_CODE = ${@dimension_value_code}"/>
        <ns1:query-field name="dimension_value_description" dataType="java.lang.String" queryExpression="v.DIMENSION_VALUE_DESCRIPTION = ${@dimension_value_description}"/>
        <ns1:query-field name="value_code" dataType="java.lang.String" queryExpression="v.DIMENSION_VALUE_CODE like &apos;%&apos;||${@value_code}||&apos;%&apos;"/>
        <ns1:query-field name="value_desc" dataType="java.lang.String" queryExpression="v.DIMENSION_VALUE_DESCRIPTION like &apos;%&apos;||${@value_desc}||&apos;%&apos;"/>
        <ns1:query-field name="summary_flag" dataType="java.lang.String" queryExpression="v.SUMMARY_FLAG = ${@summary_flag}"/>
    </ns1:query-fields>
</ns1:model>
