How To Use For Loop In Postgresql