:	'(c) Copyright	Empress Software Inc.	1983, 1998.'

USAGE="*** Usage ***  $0  : This script is for Empress internal use only"

case "$CNVDB" in
 "")
	echo "$USAGE"
	exit 1
	;;
esac

. $EMPRESSPATH/config/options

UE_E0_CVV2_INFO1=10150
UE_E0_CVV2_INFO6=10176

case "$MSINST_OLDVERS" in
 "")    $NLSECHO "
	Sorry, during installation you did not mention that your current version
	of Empress is an upgrade from an older version. You should:
	   change directory to %s, and
	   run the script \'%s\'
	to configure the conversion utilities.
	Aborting.
	" $UE_E0_CVV2_INFO6 $EMPRESSPATH/rdbms empugprd
	exit 1
	;;
esac

case "$MSINST_OLDVERSPATH" in
  "")
	  $NLSECHO "Older version of Empress installation is not valid" $UE_E0_CVV2_INFO1
	  exit 1
	  ;;
esac

case "$CNVDB_VER" in
 v2* | v4.0 )
	;;
 * )
	exit 0  
	;;
esac

for i in `$EMPRESSPATH/bin/empcmd $CNVDB "select tab_name from sys_tables \
	where tab_name not in ('sys_dictionary', 'sys_tables', 'sys_privs', 'sys_attrs', 'sys_attr_privs' ) and tab_name match \"sys_*\" dump;`
do
	NUM=`$EMPRESSPATH/bin/empcmd $CNVDB "select tab_number from sys_tables \
		where tab_name = \"$i\" dump;"`
	case "$NUM" in
	  "")	;;
	  *)	echo "$i"
		GENQUAL="attr_tabnum = $NUM"
		CHARQUAL="and attr_dtname = \"char\" and attr_dtpar1 != 1"
		TEXTQUAL="and attr_dtname = \"text\""
		case "$i" in
		  "sys_4gl_field")
		 	SPECQUAL="and attr_name != \"next_number\" and \
				attr_name != \"previous_number\"";;
		  "sys_4gl_script")
		 	SPECQUAL="and attr_name != \"return_type\"";;
		  "sys_ag_menu")
		 	SPECQUAL="and attr_name != \"type\"";;
		  "sys_ag_qualification")
		 	SPECQUAL="and attr_name != \"not_and\"";;
		  *)
			SPECQUAL="";;
		esac

		$EMPRESSPATH/bin/empcmd $CNVDB "update sys_attrs set \
			attr_dtname to \"nlschar\" where $GENQUAL \
			$SPECQUAL $CHARQUAL"
		$EMPRESSPATH/bin/empcmd $CNVDB "update sys_attrs set \
			attr_dtname to \"nlstext\" where $GENQUAL \
			$SPECQUAL $TEXTQUAL"
	  	;;
	esac
done

