0001 function new = DBDuplicate(old,new,varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 CheckMyM;
0039
0040
0041 if nargin < 2,
0042 error('Incorrect number of parameters (type ''help <a href="matlab:help DBDuplicate">DBDuplicate</a>'' for details).');
0043 end
0044 if ~isastring(old),
0045 error('Incorrect old database name (type ''help <a href="matlab:help DBDuplicate">DBDuplicate</a>'' for details).');
0046 end
0047 if ~isastring(new),
0048 error('Incorrect new database name (type ''help <a href="matlab:help DBDuplicate">DBDuplicate</a>'' for details).');
0049 end
0050
0051
0052 new = InsertDate(new);
0053
0054
0055 current = DBUse;
0056 try
0057 DBUse(old);
0058 catch
0059 error(['Database ''' old ''' not found (type ''help <a href="matlab:help DBDuplicate">DBDuplicate</a>'' for details).']);
0060 end
0061
0062 DBCreate(new);
0063 if ~isempty(current), DBUse(current); end
0064
0065
0066 try
0067 h = mym(['insert into ' new '.' 'figures select * from ' old '.figures']);
0068 h = mym(['insert into ' new '.' 'variables select * from ' old '.variables']);
0069
0070 storage = DBExternalStoragePath;
0071 sourceDirectory = [storage '/' old];
0072 targetDirectory = [storage '/' new];
0073 if ~copyfile(sourceDirectory,targetDirectory),
0074 error(['Could not copy external storage for database ''' new '''.']);
0075 end
0076 catch
0077 error('FMAToolbox:DBDuplicate:copyDB',['Could not copy database ''' new '''.']);
0078 end