There is no definite answer as to why there is a function sequence error ... I have come across it for numerous reasons .. The latest one was when an execute was called before prepare ..
Your db2 cli trace will help in identifying the cause
Visit the tip of the month section in
www.db2click.com for CLI and JDBC trace settings
Cheers
Sathyaram