Since an LTPDA repository is just a MySQL database, you can query the database using standard SQL commands via any of the popular MySQL clients. In addition, the LTPDA toolbox provides a simplified command that can be used to execute simple queries with only basic SQL knowledge. The command is called ltpda_dbquery and it can be used to perform various queries.


Searching particular tables

it takes the following input arguments:
serverA server hostname
dbnameThe name of the database to query
tablenameThe name of the table to search
queryThe query string

Examples of usage are:
   >> info  = ltpda_dbquery(server, dbname, 'objmeta', 'id>1000 and id<2000');
   >> info  = ltpda_dbquery(server, dbname, 'objmeta', 'name like "x12"');
   >> info  = ltpda_dbquery(server, dbname, 'users',        'username="aouser"');
   >> info  = ltpda_dbquery(server, dbname, 'collections',  'obj_ids="1, 2"');
   >> info  = ltpda_dbquery(server, dbname, 'transactions', 'user_id=3');
   >> info  = ltpda_dbquery(server, dbname, 'transactions', 'obj_id=56');

Retrieving a list of tables

You can retrieve a list of the tables in a database with the call:
		>> info  = ltpda_dbquery(server, dbname)
	

Executing SQL statements

For those users who know SQL, the LTPDA toolbox provides a simple mechanism to execute them. The following examples show some typical SQL statements:
		% Get a list of tables
		info  = ltpda_dbquery(server, dbname, 'show tables')
		
		% Get a table description
		info  = ltpda_dbquery(server, dbname, 'describe objmeta')
		
		% Get a list of all AO IDs 
		info  = ltpda_dbquery(server, dbname, 'select obj_id from objmeta where obj_type="ao"')	
		
		% Find all objects submitted in a particular time range 
		q = ['select obj_id from transactions where '...
		     'transdate>"2007-11-14 00:00:00" and '...
		     'transdate<"2007-11-15 00:00:00"'];
		info  = ltpda_dbquery(server, dbname, q)