cursreg returns all rows on "continguts" that not have registers on classcont. (this is ok) But i need to insert on "classcont" the int recived on function (classificado int) for each result.
CREATE OR REPLACE FUNCTION fclassifica(clasificado int) RETURNS void AS $$
DECLARE
registre RECORD;
cursreg CURSOR FOR SELECT c.idcontingut FROM continguts as c
WHERE NOT EXISTS (SELECT * FROM classcont as ca
WHERE c.idcontingut = ca.contingut);
BEGIN
OPEN cursreg;
LOOP
FETCH FROM cursreg INTO registre;
INSERT INTO classcont (class,contingut)
VALUES (clasificado, registre.idcontingut);
RAISE NOTICE 'La classificació de ID ha estat modificada' ;
END LOOP;
CLOSE cursreg;
RETURN ;
END;
$$ LANGUAGE plpgsql;