I do execute similar code in a different sub routine. The only difference is the sql statement.
In this code I am executing a stored proc in the other code I am executing a select statement that fetches the database name.
The $$dbh is correct. We use our own module that passes back references from $app.