split typecast method into two

one method for fetching data and one for sending to db.

fixes #2287
fine with me.