0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % Get a list of database fields
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % M Hewitson
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % $Id: getFields.m,v 1.3 2011/04/08 08:56:25 hewitson Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 function fields = getFields(mainfig, conn)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 if ~isempty(conn)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % get the selected table
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 tblSel = findobj(mainfig.handle, 'Tag', 'tableSelect');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 tbls = get(tblSel, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 tbl = tbls{get(tblSel, 'Value')};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % get the databases
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 q = sprintf('describe %s', tbl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 curs = exec(conn, q);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 curs = fetch(curs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 fields = curs.Data(:,1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 close(curs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 disp(sprintf('### Server returned: %s', curs.Message));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 warning('!!! Can not read from database');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 fields = {'-'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 fields = {'-'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 end
|