system($cmd)==0ordie("error encountered when updating database $xdbname\n");
#get distinct db_names for an object type
my$external_db_sth=$dba->dbc()->prepare("select distinct external_db_id from object_xref join xref using(xref_id) join external_db using(external_db_id) where ensembl_object_type = ? and info_type != 'UNMAPPED' order by db_name");
#get xref types for an object type and external db
my$xref_types_sth=$dba->dbc()->prepare("select distinct info_type from object_xref join xref using(xref_id) where ensembl_object_type = ? and external_db_id = ? and info_type != 'UNMAPPED'");
#get master xref db_names
my$master_db_sth=$dba->dbc()->prepare("select distinct e.external_db_id from object_xref ox join xref x1 on (ox.xref_id = x1.xref_id) join dependent_xref on (x1.xref_id = dependent_xref_id) join xref x2 on (master_xref_id = x2.xref_id) join external_db e on (x2.external_db_id = e.external_db_id) where ensembl_object_type = ? and x1.external_db_id = ? and x1.info_type != 'UNMAPPED'");
#get species from which xrefs were projected
my$projected_from_species_sth=$dba->dbc()->prepare("select distinct substr(info_text,1,locate(' ', info_text, locate(' ', info_text)+1 )) from object_xref join xref using(xref_id) where info_text like 'from%' and ensembl_object_type = ? and external_db_id = ? and info_type = 'PROJECTION'");
#xref_mindmap db statements
my$insert_object_xref_linkage=$dbh->prepare("insert into object_xref_linkage values(?,?,?,?,?)");
my$insert_object_external_db_node=$dbh->prepare("insert into object_external_db_node values (?,?,?)");
my$link_type_sth=$dbh->prepare("select link_type_id from link_type where link_type = ?");
my$category_and_db_name_nodes_sth=$dbh->prepare("select db_type, external_db_id, db_display_name, mindmap_tag_id from object_external_db_node join external_db_type using(external_db_id) join db_type using(db_type_id) where ensembl_object_type = ? order by db_type, db_display_name;");
my$db_linkage_types_sth=$dbh->prepare("select link_description, linked_external_db_id, linked_node_text from object_xref_linkage join link_type using(link_type_id) where ensembl_object_type = ? and external_db_id = ? and link_description is not null order by link_description, linked_external_db_id, linked_node_text");
#this is used to link to dbs from the closest level (e.g. if Orphanet xrefs for a Gene are dependent on HGNC xrefs
#we will try to link to the Gene HGNC node then transcript etc..
my$object_distance_sth=$dbh->prepare("select to_object from object_distance where from_object = ? order by distance");
my$node_id_sth=$dbh->prepare("select mindmap_tag_id from object_external_db_node where ensembl_object_type = ? and external_db_id = ?");