
echo 
echo "    ACCOUNTFLEX DATABASE CONVERSION"
echo 

echo 
echo "Building New Database"
echo 
sqlbuild -convert
if test $? -ne 0; then
  echo
  echo " !!!!  Build failed !!!!" 
  echo "       CALL FOR SUPPORT    "
else
  echo
  echo "Build completed successfully !!!"
  echo
fi

echo 
echo "Creating SQL script for converting"
echo 
# Make sure old database has DBA permissions
fxsql2 grant2.sql   
FXDATA2=$FXAPDIR/actnew.dbs; export FXDATA2
rm -rf convert.sql
fxsql2 infocmp > convert.sql

if test -f convert.sql; then
    FXSIZE=`wc convert.sql | awk '{ print $1 }'`
    if test "$FXSIZE" != "0"; then
       echo 
       echo "Converting OLD database"
       echo  
       fxsql convert.sql
    fi
fi
if test $? -ne 0; then
  echo
  echo " !!!!  Conversion failed !!!!" 
  echo "       CALL FOR SUPPORT    "
  exit 1
fi

fxsql2 menucmp

echo
echo "Conversion completed successfully !!!"
echo

