You should implement your own workflow and then you can use javascript or beanshell scripts to do things in tasks or nodes. To connect to database I think you could write you own java code for that and expose it as JS extension in alfresco.
ok I've been searching and I figured out how to fill a drop down list but I like to know how to insert a new value in any database, a value from a WF or data list