<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">
	<query id="CoreSpecificationsBasicsSupplement.QUERY" desc="权限功能">
		<![CDATA[
			SELECT  'FALSE' spchk,
					'False' CHK,
					ORDER_SPEC_CODE,
				    ORDER_SPEC_DESC,
				    SPEC_CODE,
					SPEC_NAME,
					CREATE_NAME,
					TO_CHAR(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
					UPDATE_NAME,
					TO_CHAR(UPDATE_TIME,'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
					DELETE_NAME,
					TO_CHAR(DELETE_TIME,'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
					VALIDFLAG,
					decode(VALIDFLAG,'1','有效','无效') VALIDFLAGNAME,
					MEMO
				FROM COM_BASE_SPEC_ORDER
				   WHERE SPEC_CODE = ?
				   AND VALIDFLAG in ('1' , ?)
				   ORDER BY ORDER_SPEC_CODE
		]]>
	</query>
	
	<query id="CoreSpecificationsBasicsSupplement.Save" desc="保存">
		<![CDATA[
			DECLARE
			  P_SPEC_CODE COM_BASE_SPEC_ORDER.SPEC_CODE%TYPE := ':SPEC_CODE';
			  P_ORDER_SPEC_DESC COM_BASE_SPEC_ORDER.ORDER_SPEC_DESC%TYPE := ':ORDER_SPEC_DESC';
			  P_ORDER_SPEC_CODE COM_BASE_SPEC_ORDER.ORDER_SPEC_CODE%TYPE := ':ORDER_SPEC_CODE';
			  P_SPEC_NAME COM_BASE_SPEC_ORDER.SPEC_NAME%TYPE := ':SPEC_NAME';
			  P_NAME COM_BASE_SPEC_ORDER.CREATE_NAME%TYPE := ':CREATE_NAME';
			  P_MEMO COM_BASE_SPEC_ORDER.MEMO%TYPE := ':MEMO';
			  P_COUNT NUMBER(5);
			
			BEGIN
			     SELECT COUNT(1) INTO P_COUNT FROM COM_BASE_SPEC_ORDER WHERE ORDER_SPEC_CODE = P_ORDER_SPEC_CODE;
			     IF P_COUNT = 0 THEN
			        INSERT INTO COM_BASE_SPEC_ORDER
							(ORDER_SPEC_CODE,
					        ORDER_SPEC_DESC,
					        SPEC_CODE,
					        SPEC_NAME,
					        CREATE_NAME,
					        CREATE_TIME,
					        VALIDFLAG,
					        MEMO)
							VALUES(
							(SELECT P_SPEC_CODE || 'DH' ||
							       LPAD((NVL((TO_NUMBER(SUBSTR(MAX(T.ORDER_SPEC_CODE), 10, 6)) + 1), 1)),
							             6,
							             '0') ORDER_SPEC_CODE
							  FROM com_base_spec_order T
							 WHERE T.SPEC_CODE = P_SPEC_CODE),
							P_ORDER_SPEC_DESC,P_SPEC_CODE,P_SPEC_NAME,
							P_NAME,SYSDATE,
							1,P_MEMO);
			     ELSE
			         UPDATE COM_BASE_SPEC_ORDER set
							ORDER_SPEC_DESC= P_ORDER_SPEC_DESC, 
							UPDATE_NAME= P_NAME, 
							UPDATE_TIME= SYSDATE,
							MEMO= P_MEMO
							WHERE ORDER_SPEC_CODE= P_ORDER_SPEC_CODE;
			     END IF;
			END;
		]]>
	</query>
	
	<query id="CoreSpecificationsBasicsSupplement.ADD" desc="新增">
		<![CDATA[
			 INSERT INTO COM_BASE_SPEC_ORDER
							(ORDER_SPEC_CODE,
					        ORDER_SPEC_DESC,
					        SPEC_CODE,
					        SPEC_NAME,
					        CREATE_NAME,
					        CREATE_TIME,
					        VALIDFLAG,
					        MEMO)
							VALUES(
							(SELECT ? || 'DH' ||
							       LPAD((NVL((TO_NUMBER(SUBSTR(MAX(T.ORDER_SPEC_CODE), 10, 6)) + 1), 1)),
							             6,
							             '0') ORDER_SPEC_CODE
							  FROM com_base_spec_order T
							 WHERE T.SPEC_CODE = ?),
							?,?,?,
							?,SYSDATE,
							1,?)
							
			  
		]]>
	</query>
	
	<query id="CoreSpecificationsBasicsSupplement.MODIFY" desc="修改">
		<![CDATA[
			 UPDATE COM_BASE_SPEC_ORDER set
							ORDER_SPEC_DESC=?, 
							UPDATE_NAME=?, 
							UPDATE_TIME=SYSDATE,
							MEMO=? 
							WHERE ORDER_SPEC_CODE=?
		]]>
	</query>
	<query id="CoreSpecificationsBasicsSupplement.DELETE" desc="作废">
		<![CDATA[
			 UPDATE COM_BASE_SPEC_ORDER T
			   SET T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE, T.VALIDFLAG = '0'
			 WHERE T.ORDER_SPEC_CODE = ?
		]]>
	</query>
	
	<query id="CoreSpecificationsBasicsSupplement.RESUME" desc="恢复">
		<![CDATA[
			UPDATE COM_BASE_SPEC_ORDER T
               SET T.DELETE_NAME = '', T.DELETE_TIME = '', T.VALIDFLAG = '1'
             WHERE T.ORDER_SPEC_CODE = ?
		]]>
	</query>
</queryMap>