view m-toolbox/classes/@repogui/getFields.m @ 25:79dc7091dbbc
database-connection-manager
Update tests
author
Daniele Nicolodi <nicolodi@science.unitn.it>
date
Mon, 05 Dec 2011 16:20:06 +0100 (2011-12-05)
parents
f0afece42f48
children
line source
+ − % Get a list of database fields
+ − %
+ − % M Hewitson
+ − %
+ − % $Id: getFields.m,v 1.3 2011/04/08 08:56:25 hewitson Exp $
+ − %
+ − function fields = getFields(mainfig, conn)
+ −
+ −
+ − if ~isempty(conn)
+ − % get the selected table
+ − tblSel = findobj(mainfig.handle, 'Tag', 'tableSelect');
+ − tbls = get(tblSel, 'String');
+ − tbl = tbls{get(tblSel, 'Value')};
+ − % get the databases
+ − try
+ − q = sprintf('describe %s', tbl);
+ − curs = exec(conn, q);
+ − curs = fetch(curs);
+ − fields = curs.Data(:,1);
+ − close(curs);
+ − catch
+ − disp(sprintf('### Server returned: %s', curs.Message));
+ − warning('!!! Can not read from database');
+ − fields = {'-'};
+ − end
+ − else
+ − fields = {'-'};
+ − end
+ −
+ − end