Les Curseurs (3/4)
CREATE OR REPLACE FUNCTION fct() RETURNS void AS $$
DECLARE
rec RECORD;
curs refcursor;
BEGIN
EXECUTE 'CREATE TABLE temp (idliv integer, titre varchar(50))';
OPEN curs FOR SELECT liv_num, liv_titre FROM livre;
LOOP
FETCH curs INTO rec;
EXIT WHEN NOT FOUND;
INSERT INTO temp VALUES(rec.liv_num,rec.liv_titre);
END LOOP;
CLOSE curs;
END;
$$ LANGUAGE plpgsql;