Check out the Meta Data Source, I'm pretty sure that it has the functions you are looking for. The SQL module is meant to connect to an external database. With the Meta Data Source you can return the value of a point from the history and also apply scripts to its along with many other features.