Bonjour, je voudrais faire une fonction qui renvoie le résultat d'un count() tout simple sur une table :
Puis j'effectue un select sur la fonction :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 CREATE FUNCTION hs_data_get_hs_new_count_from_old(INTEGER) RETURNS SETOF RECORD AS ' DECLARE unigene ALIAS FOR $1; rec RECORD; BEGIN FOR rec IN SELECT COUNT(hs_new), hs_old FROM hs_l GROUP BY hs_old HAVING hs_old = unigene LOOP RETURN NEXT rec; END LOOP; RETURN; END; ' LANGUAGE 'PLPGSQL';
select * from hs_data_get_hs_new_count_from_old('278468') as (compt int, uni int);
Mais là j'ai une erreur :
ERREUR: wrong record type supplied in RETURN NEXT
CONTEXT: PL/pgSQL function "hs_data_get_hs_new_count_from_old" line 7 at return next
Est-ce que vous verriez où peut bien être le vice ?![]()
En vous remerciant,
C. Tobini
Partager