return: integer
|
|
lang: plpgsql
|
|
parameters:
|
|
p0:
|
|
type: bigint
|
|
name: i_rapport_id
|
|
src: |
|
|
DECLARE
|
|
|
|
|
|
temp_cursor refcursor;
|
|
_oid integer;
|
|
_maxind integer;
|
|
BEGIN
|
|
|
|
_maxind = 100;
|
|
IF i_rapport_id <> 0 THEN
|
|
|
|
OPEN temp_cursor FOR
|
|
SELECT MAX(oid)
|
|
FROM activite.t_indicateurs
|
|
WHERE oid IN (
|
|
SELECT base.cti_unnest(Array[indicateur_id, indicateur_associe_1_id, indicateur_associe_2_id, indicateur_associe_3_id, indicateur_associe_4_id, indicateur_associe_5_id, indicateur_associe_6_id, indicateur_associe_7_id])
|
|
FROM activite.t_rapports
|
|
JOIN activite.t_rapports_rubriques ON t_rapports.oid = t_rapports_rubriques.rapport_id AND rapport_id = i_rapport_id
|
|
JOIN activite.t_indicateurs ON t_rapports_rubriques.indicateur_id = t_indicateurs.oid);
|
|
ELSE
|
|
OPEN temp_cursor FOR
|
|
SELECT MAX(oid)
|
|
FROM activite.t_indicateurs;
|
|
END IF;
|
|
|
|
FETCH temp_cursor INTO _oid;
|
|
WHILE FOUND LOOP
|
|
_maxind = _oid;
|
|
FETCH temp_cursor INTO _oid;
|
|
END LOOP;
|
|
CLOSE temp_cursor;
|
|
|
|
RETURN _maxind;
|
|
END;
|