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