Home > FMAToolbox > Database > DBRemove.m

DBRemove

PURPOSE ^

DBRemove - Remove database.

SYNOPSIS ^

function DBRemove(database)

DESCRIPTION ^

DBRemove - Remove database.

  Actual removal will require confirmation from the user.

  USAGE

    DBRemove(database)

    database       database name

  SEE

    See also DBRemove, DBRemoveFigures, DBRemoveVariables.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function DBRemove(database)
0002 
0003 %DBRemove - Remove database.
0004 %
0005 %  Actual removal will require confirmation from the user.
0006 %
0007 %  USAGE
0008 %
0009 %    DBRemove(database)
0010 %
0011 %    database       database name
0012 %
0013 %  SEE
0014 %
0015 %    See also DBRemove, DBRemoveFigures, DBRemoveVariables.
0016 %
0017 
0018 % Copyright (C) 2007-2016 by Michaël Zugaro
0019 %
0020 % This program is free software; you can redistribute it and/or modify
0021 % it under the terms of the GNU General Public License as published by
0022 % the Free Software Foundation; either version 3 of the License, or
0023 % (at your option) any later version.
0024 
0025 % Make sure MyM is installed and functional
0026 CheckMyM;
0027 
0028 % Check parameters
0029 if nargin < 1,
0030   error('Incorrect number of parameters (type ''help <a href="matlab:help DBRemove">DBRemove</a>'' for details).');
0031 end
0032 if ~isastring(database),
0033   error('Incorrect database name (type ''help <a href="matlab:help DBRemove">DBRemove</a>'' for details).');
0034 end
0035 
0036 % Select database
0037 try
0038     h = mym(['use ' database]);
0039 catch
0040     error(['Could not find database ''' database '''.']);
0041 end
0042 
0043 % Print warning and display # figures and # variables to remove
0044 disp(' ');
0045 f = mym(['select name from figures']);
0046 if length(f) > 1, sf = 's'; else sf = ''; end
0047 v = mym(['select name from variables']);
0048 if length(v) > 1, sv = 's'; else sv = ''; end
0049 disp(['This would remove ''' database ''' (' int2str(length(f.name)) ' figure' sf ', ' int2str(length(v.name)) ' variable' sv ').']);
0050 
0051 % Confirm
0052 s = lower(input('Type ''remove'' to confirm: ','s'));
0053 if ~strcmp(s,'remove'),
0054     disp('*** Cancelled ***');
0055     return
0056 end
0057 
0058 % Remove external storage if necessary
0059 try
0060     storage = DBExternalStoragePath;
0061     targetDirectory = [storage '/' database];
0062     rmdir(targetDirectory,'s');
0063 end
0064     
0065 % Remove
0066 mym(['drop database ' database]);
0067 disp('Database removed.');

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005