Incomming call routing by external program or db table

I am searching for a way to redirect incomming call to some destinations based an external program or table. I am thinking about something similar to the caller-id lookup services that can search for the caller-id text by quering some sources.

Is there any clean way for doing this for the incomming call routing?

There is the third party module Dynamic Routing that will route calls based in an SQL query.