Postgresql Stored Procedure Loop Through Array