Mercurial > hg > ltpda
diff m-toolbox/classes/tests/database/@ltpda_cdata_table/getTableEntry.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children | 79dc7091dbbc |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/tests/database/@ltpda_cdata_table/getTableEntry.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,35 @@ +% +% DESCRIPTION: Returns a table enty for the given inputs: database table, +% column name, object ID +% +% VERSION: $Id: getTableEntry.m,v 1.1 2011/05/25 16:25:31 ingo Exp $ +% +function val = getTableEntry(utp, dbTable, tableField, objID) + + % Check database version + if 1==1 + %%% old database layout + + try + % Get the data ID from the ao table + dataID = getDataIdFromAoTable(utp, objID); + + % Check that we get only one result for the query + assert(numel(dataID)==1, sprintf('Found more than one data ID for the given object ID %d', objID)); + + % Create query to get the field 'xunits' from the 'cdata' table + query = sprintf('SELECT %s FROM %s WHERE %s.id=%d', tableField, dbTable, dbTable, dataID{1}); + val = executeQuery(utp, query); + catch Me + rethrow(Me); + end + + elseif 1~=1 + %%% new database layout + else + throw(MException('ltpda_cdata_table:getTableEntry', 'Unknown database layout.')); + end + + utp.conn.setLocked(false); + utp.conn.closeConnection(); +end