Adding a criterion that contains a sql-query, 5 adding a criterion that contains a sql-query – Grass Valley K2 TX/MAM Database Protocol Manual v.2.2 User Manual
Page 12

TX/MAM Database Protocol Manual - document version: 2.2
– Page 12
6.5 Adding a criterion that contains a SQL-query
The SQL-query can only be a 'read only' query and should always return the fields 'ID' and
'SAVE_STAMP'. For a reference on the SQL 'select' statement, please refer to
The values to compare the fields with can be put directly into the SQL-statement (e.g.
“where
id_Playlist = 1
”), except when the field is a string field. In this case the value should be passed using
a parameter. This means that the SQL-statement will contain for example
“where asset_string
= :asset_string
” and the cob_criteria_add_sqlparam function will be used to provide the
value, for example cob_criteria_add_sqlparam( “asset_element”, “asset_string”,
”Clips” ).
A cob_criteria_add_sqlquery() should only be executed once for every
cob_get_id_lis()call. Multiple parameters can be added per cob_get_id_list()call.
int cob_criteria_add_sqlquery( char *table, char *value );
Parameters
Name
Description
char *table
The table from which to use the field, e.g. "asset_element".
char *value
The SQL-query e.g. "select id, save_stamp from asset_element where
status_int = 1".
Result
The result of the function is an integer that can have following values:
Value
Description
0
Success, the criterion has been added
-1
Failure, the criterion could not be added
Example
This example will retrieve a list of all asset_elements with an asset_string value that equals "Clips"
and with status_int value that equals 1:
cob_criteria_clear();
cob_criteria_add_sqlquery( "asset_element","select id,savestamp from asset_element where ”
"asset_string = :asset_string and status_int=1" );
cob_criteria_add_sqlparam( "asset_element", "asset_string", "Clips" );
number_of_ids = cob_get_id_list( id_array, max_id_size );