Function utilisation Perform
Bonjour,
J'ai créé la fonction suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
CREATE FUNCTION brain.update_hash_people ()
RETURNS bool
LANGUAGE plpgsql
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 1
AS $$
DECLARE
v_id_people int;
v_hash varchar;
BEGIN
-- génère les hash
FOR v_id_people,v_hash
IN select id_people,hash from brain.update_hash
LOOP
select id_people from brain.people where id_people = v_id_people and hash = v_hash;
if not found THEN
update brain.people set hash = v_hash, modification = false;
end if;
END LOOP;
return true;
END;
$$; |
du coup j'ai l'erreur suivante :
Citation:
SQL Error [42601]: ERROR: query has no destination for result data
Indice*: If you want to discard the results of a SELECT, use PERFORM instead.
Où*: PL/pgSQL function update_hash_people() line 10 at SQL statement
Je modifie donc comme ceci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
CREATE FUNCTION brain.update_hash_people ()
RETURNS bool
LANGUAGE plpgsql
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 1
AS $$
DECLARE
v_id_people int;
v_hash varchar;
BEGIN
-- génère les hash
FOR v_id_people,v_hash
IN select id_people,hash from brain.update_hash
LOOP
perform id_people from brain.people where id_people = v_id_people and hash = v_hash;
if not found THEN
update brain.people set hash = v_hash, modification = false;
end if;
END LOOP;
return true;
END;
$$; |
Et là cela tourne en boucle, j’arrête après plusieurs minutes.
Pouvez-vous m'orienter vers une solution ?
Merci