Curseur de documents dans PostgreSQL

Je suis en train d'utiliser les curseurs pour une requête qui joint plusieurs tables. J'ai vu que pour oracle, il y a un curseur à l'enregistrement de base. Quand j'ai essayer la même chose pour Postgres, il lève une erreur. Comment puis-je faire la même chose dans Postgres?

CREATE OR REPLACE FUNCTION avoidable_states()
RETURNS SETOF varchar AS
$BODY$
DECLARE
    xyz CURSOR FOR select * from address ad
                            join city ct on ad.city_id = ct.city_id;    
    xyz_row RECORD;
BEGIN   
    open xyz;

    LOOP
    fetch xyz into xyz_row;
        exit when xyz_row = null;
        if xyz_row.city like '%hi%' then
            return next xyz_row.city;               
        end if;
    END LOOP;
    close xyz;  
END;
$BODY$
  LANGUAGE plpgsql VOLATILE;

D'erreur que je reçois est:

ERROR:  relation "xyz" does not exist
CONTEXT:  compilation of PL/pgSQL function "avoidable_states" near line 4

OriginalL'auteur Zeus | 2014-03-12