Mercurial > hg > ltpda
comparison m-toolbox/classes/tests/database/@ltpda_xydata_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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % | |
2 % DESCRIPTION: Returns a table enty for the given inputs: database table, | |
3 % column name, object ID | |
4 % | |
5 % VERSION: $Id: getTableEntry.m,v 1.1 2011/05/25 16:25:31 ingo Exp $ | |
6 % | |
7 function val = getTableEntry(utp, dbTable, tableField, objID) | |
8 | |
9 % Check database version | |
10 if 1==1 | |
11 %%% old database layout | |
12 | |
13 try | |
14 % Get the data ID from the ao table | |
15 dataID = getDataIdFromAoTable(utp, objID); | |
16 | |
17 % Check that we get only one result for the query | |
18 assert(numel(dataID)==1, sprintf('Found more than one data ID for the given object ID %d', objID)); | |
19 | |
20 % Create query to get the field 'xunits' from the 'cdata' table | |
21 query = sprintf('SELECT %s FROM %s WHERE %s.id=%d', tableField, dbTable, dbTable, dataID{1}); | |
22 val = executeQuery(utp, query); | |
23 catch Me | |
24 rethrow(Me); | |
25 end | |
26 | |
27 elseif 1~=1 | |
28 %%% new database layout | |
29 else | |
30 throw(MException('ltpda_cdata_table:getTableEntry', 'Unknown database layout.')); | |
31 end | |
32 | |
33 utp.conn.setLocked(false); | |
34 utp.conn.closeConnection(); | |
35 end |