Postgresql Plpgsql Loop Through Array Python Initialize Variable To Null