In some RPG shops, all programs are compiled with
USRPRF(*OWNER) and the owner of all programs is set to a specific user profile, which has the proper object authority to the database files. No other regular user profiles are granted authority to the files. In this scenario, the SQL service program will not have authority to any files and the query will fail. The solution to this is to change the service program so that it also uses adopted authority.
Changing the Service Program
This can be done with the following two commands where THE_OWNER is the user profile that has the correct authority to read the database files.