What does your CONNECT statement look like and what database are you connection to?
Are you stating that you connect successfully in a called subprogram and you can access the database fine but then when you do an exit program to return to the main program you get a -19702 error on another sql statement?
Do you cancel the subprogram after returning?