updated dbfunction and better code to loop pcode on Hotel db table