Home > FMAToolbox > Database > DBRemoveFigures.m

DBRemoveFigures

PURPOSE ^

DBRemoveFigures - Remove all figures that match given criteria.

SYNOPSIS ^

function DBRemoveFigures(query)

DESCRIPTION ^

DBRemoveFigures - Remove all figures that match given criteria.

  Actual removal will require confirmation from the user.

  USAGE

    DBRemoveFigures(query)

    query          optional figure list query (WHERE clause; see Example)

  SEE

    See also DBAddFigure, DBGetFigures, DBRemove.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function DBRemoveFigures(query)
0002 
0003 %DBRemoveFigures - Remove all figures that match given criteria.
0004 %
0005 %  Actual removal will require confirmation from the user.
0006 %
0007 %  USAGE
0008 %
0009 %    DBRemoveFigures(query)
0010 %
0011 %    query          optional figure list query (WHERE clause; see Example)
0012 %
0013 %  SEE
0014 %
0015 %    See also DBAddFigure, DBGetFigures, DBRemove.
0016 %
0017 
0018 % Copyright (C) 2007-2013 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 % Optional query provided?
0029 if nargin == 0,
0030     query = '';
0031 end
0032 
0033 % Edit query
0034 query = strtrim(query);
0035 query = regexprep(query,'^where','');
0036 if ~isempty(query), query = [' where ' query]; end
0037 
0038 % Get database name
0039 database = DBUse;
0040 
0041 % Query database
0042 f = mym(['select eid,name from figures' query]);
0043 
0044 % Make sure query results are not empty
0045 if isempty(f.eid),
0046     if isempty(query),
0047         warning(['No figures in ''' database '''.']);
0048     else
0049         warning(['No figures match (' query ').']);
0050     end
0051     return
0052 end
0053 
0054 % Print warning and display figures to remove
0055 disp(' ');
0056 disp(['This would remove the following figures from ''' database ''':']);
0057 DBDisplay(f);
0058 
0059 % Confirm
0060 s = lower(input('Type ''remove'' to confirm: ','s'));
0061 if ~strcmp(s,'remove'),
0062     disp('*** Cancelled ***');
0063     return
0064 end
0065 
0066 % Remove
0067 mym(['delete from figures' query]);
0068 disp('Figures removed.');

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