rem
rem   Called from RON to check whether UE definitions of XT tables
rem
DECLARE
   DIFF_ERROR EXCEPTION;
   FUNCTION ISDIFF(TYPE VARCHAR2) RETURN BOOLEAN IS
      DUMMY NUMBER;
   BEGIN 
   IF  (TYPE = 'TT') THEN
      SELECT 1 
      INTO DUMMY
      FROM SYS.DUAL 
      WHERE EXISTS
      (  SELECT TEXT_TYPE
         ,      DESCRIPTION
         ,      IS_EXTENDED 
         ,      IS_PUBLISHED 
         FROM   XT_CIUE_TEXT_TYPES
         MINUS
         SELECT TEXT_TYPE
         ,      DESCRIPTION
         ,      IS_EXTENDED   
         ,      IS_PUBLISHED 
         FROM   CIUE_TEXT_TYPES
         WHERE  IS_EXTENDED = 'Y');
     END IF;
    
    IF  (TYPE = 'TU') THEN
      SELECT 1 
      INTO DUMMY
      FROM SYS.DUAL 
      WHERE EXISTS
      (	 SELECT XT.TEXT_TYPE
	 ,      XT.XT_TU_SHORT_NAME SHORT_NAME
	 ,      NAME
	 ,      XT.IS_EXTENDED 
	 ,      XT.IS_PUBLISHED 
	 FROM   XT_CIUE_TEXT_USAGES  XT
	 ,      RM_ELEMENT_TYPES     ET
	 WHERE  XT.ELEMENT_TYPE = ET.ID
	 MINUS
	 SELECT CI.TEXT_TYPE
	 ,      ET.SHORT_NAME
	 ,      NAME
	 ,      CI.IS_EXTENDED 
	 ,      CI.IS_PUBLISHED 
	 FROM   CIUE_TEXT_USAGES     CI
	 ,      RM_ELEMENT_TYPES     ET
	 WHERE  CI.ELEMENT_TYPE = ET.ID
	 AND    CI.IS_EXTENDED = 'Y');
   END IF;

   IF  (TYPE = 'ET') THEN
      SELECT 1 
      INTO DUMMY
      FROM SYS.DUAL 
      WHERE EXISTS
      (  SELECT SHORT_NAME
	 ,      NAME
	 ,      IS_USER_TYPE
	 ,      IS_EXTENDED 
	 ,      IS_PUBLISHED 
	 FROM   XT_CIUE_ELEMENT_TYPES
	 MINUS
	 SELECT SHORT_NAME
	 ,      NAME
	 ,      IS_USER_TYPE
	 ,      IS_EXTENDED 
	 ,      IS_PUBLISHED 
	 FROM   CIUE_ELEMENT_TYPES
	 WHERE  IS_EXTENDED = 'Y');
   END IF;

   IF  (TYPE = 'ASSOC') THEN
      SELECT 1 
      INTO DUMMY
      FROM SYS.DUAL 
      WHERE EXISTS
      (	 SELECT SHORT_NAME
	 ,      NAME
	 ,      PART_OF_SHORT_NAME 
	 ,      USE_OF_SHORT_NAME 
	 ,      PART_OF_DEGREE 
         ,      USE_OF_DEGREE
	 ,      IS_USER_TYPE 
	 ,      IS_EXTENDED  
	 ,      IS_PUBLISHED 
	 FROM  XT_CIUE_ASSOCIATION_TYPES
	 MINUS
	 SELECT SHORT_NAME
         ,      NAME
         ,      PART_OF_SHORT_NAME 
         ,      USE_OF_SHORT_NAME 
         ,      PART_OF_DEGREE 
         ,      USE_OF_DEGREE
         ,      IS_USER_TYPE 
         ,      IS_EXTENDED  
         ,      IS_PUBLISHED 
	 FROM  CIUE_ASSOCIATION_TYPES
	 WHERE IS_EXTENDED = 'Y');
    END IF;

    IF  (TYPE = 'PROP') THEN
      SELECT 1 
      INTO DUMMY
      FROM SYS.DUAL 
      WHERE EXISTS
      (  SELECT       ELEMENT_TYPE_SHORT_NAME                    
         ,            ELEMENT_TYPE_NAME                          
         ,            NAME                       
         ,            DISPLAY_NAME               
         ,            DISPLAY_DATATYPE           
         ,            DISPLAY_LENGTH
         ,            DISPLAY_PRECISION 
         ,            DISPLAY_SCALE     
         ,            IS_MANDATORY               
         ,            CASE_MODE
         ,            DISPLAY_SEQUENCE  
         ,            IS_DISPLAYED               
         ,            IS_UPDATEABLE              
         ,            IS_USER_PROPERTY           
         ,            IS_EXTENDED                
         ,            IS_PUBLISHED               
         from XT_CIUE_PROPERTIES
         MINUS
         SELECT       ELEMENT_TYPE_SHORT_NAME                   
         ,            ELEMENT_TYPE_NAME                          
         ,            NAME                       
         ,            DISPLAY_NAME               
         ,            DISPLAY_DATATYPE           
         ,            DISPLAY_LENGTH
         ,            DISPLAY_PRECISION 
         ,            DISPLAY_SCALE     
         ,            IS_MANDATORY               
         ,            CASE_MODE
         ,            DISPLAY_SEQUENCE  
         ,            IS_DISPLAYED               
         ,            IS_UPDATEABLE              
         ,            IS_USER_PROPERTY           
         ,            IS_EXTENDED                
         ,            IS_PUBLISHED 
         from CIUE_PROPERTIES);
      END IF;

      RETURN (TRUE);
      
   EXCEPTION 
      WHEN NO_DATA_FOUND THEN RETURN (FALSE);
   END;

BEGIN
--   :iserror := 0;
--  :sqlcode := 0;
--  :ueDiffs := 0; 
  IF ISDIFF('TT') = TRUE THEN 
    RAISE DIFF_ERROR;
  END IF;
  IF ISDIFF('TU') = TRUE THEN 
    RAISE DIFF_ERROR;
  END IF;
  IF ISDIFF('ET') = TRUE THEN 
    RAISE DIFF_ERROR;
  END IF;
  IF ISDIFF('ASSOC') = TRUE THEN 
    RAISE DIFF_ERROR;
  END IF;
  IF ISDIFF('PROP') = TRUE THEN 
    RAISE DIFF_ERROR;
  END IF;

  EXCEPTION 
    WHEN DIFF_ERROR THEN
       :ueDiffs := 1; 
    WHEN OTHERS THEN
      rmmes.post ('ORA', SQLCODE);
      :iserror := 1;
      :sqlcode := sqlcode;
END;

