Some thoughts:
1) look at mod_lcr
2) comments on script below...
Following is the js i am using to select route and bridge the call....
use("ODBC");
var DSN = "myodbc";
var DB_USER = "neo";
var DB_PASS = ".....";
[...]
var db = new ODBC(DSN, DB_USER, DB_PASS);
db.connect();
[...]
sql = "SELECT ec.* FROM auth_routes_carriers arc,external_carriers ec, codes c where arc.external_carriers_id = ec.id and arc.code_id = c.id and substring('"+no2+"',1,length(c.code))=c.code and ec.active=1 order by arc.priority asc";
db.connect();
db.query(sql);
[...]
if(bridge_str != ''){
if(session.ready()) session.execute("bridge", bridge_str);