L3 Info : SGBD
 
◃  Ch. 11 PL/pgSQL  ▹
 

Les Curseurs (4/4)

CREATE OR REPLACE function fct() RETURNS void AS $$
DECLARE
    rec temp%ROWTYPE;
BEGIN
    execute 'DELETE FROM TEMP';
    FOR rec IN SELECT liv_num, liv_titre from livre LOOP
       INSERT INTO temp VALUES(rec.liv_num,rec.liv_titre);
    END LOOP;
END;
$$ LANGUAGE plpgsql;