0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 % DESCRIPTION: Returns a table enty for the given inputs: database table,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % column name, object ID
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % VERSION: $Id: getTableEntry.m,v 1.1 2011/05/25 16:25:31 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 function val = getTableEntry(utp, dbTable, tableField, objID)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % Check database version
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 if 1==1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 %%% old database layout
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % Get the data ID from the ao table
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 dataID = getDataIdFromAoTable(utp, objID);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % Check that we get only one result for the query
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 assert(numel(dataID)==1, sprintf('Found more than one data ID for the given object ID %d', objID));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % Create query to get the field 'xunits' from the 'cdata' table
|
25
|
21 query = sprintf('SELECT %s FROM %s WHERE %s.id = ?', tableField, dbTable, dbTable);
|
|
22 val = utils.mysql.execute(utp.conn, query, dataID{1});
|
0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 catch Me
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 rethrow(Me);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 elseif 1~=1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 %%% new database layout
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 throw(MException('ltpda_cdata_table:getTableEntry', 'Unknown database layout.'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 end
|
25
|
32
|
0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 end
|