Bonjour,
Voici mon code, il me faut du SQL dynamique car un des noms de table dépend du mois que l'on souhaite, et j'aimerai mettre le tout dans un refcurseur afin de l'utiliser ds Report.
Même si l'erreur semble évidente, je séche sur la façon d'y remédier.
Pourriez-vous m'aider SVP, ou me donnez des pistes.
Par avance, merci


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- PACKAGE
 AS
TYPE rec_coef is RECORD (
centre VARCHAR2(2000),
matricule admin.agents.agt_matricule%type,
nom admin.agents.agt_nom_marital%type,
prenom admin.agents.agt_prenom%type,
coef admin.coefficients.coef_nouveau%type
);
TYPE coef_curtyp IS REF CURSOR return rec_coef;
procedure edit_coef(i_mois IN VARCHAR2,r_coef in out coef_curtyp);
END;
 
-- CORPS DU PACKAGE
 AS
procedure edit_coef(i_mois IN VARCHAR2,r_coef in out coef_curtyp) is
i_req VARCHAR2(2000) := '
select lib_centre(substr(a.sve_code,1,1)) centre,
a.agt_matricule matricule,
a.agt_nom_marital nom,
a.agt_prenom prenom,
substr(p.zone_donnees, 9) coef
from agents a, pl_extract_'||i_mois||' p
where a.agt_matricule = ltrim(rtrim(p.matricule))
and p.code_rubrique = ''YCO''
and p.domaine = ''E''
and p.statut = ''EPIC''
order by a.agt_matricule';
r coef_curtyp;
begin
 open r for i_req;
 loop
 fetch r into r_coef;
 exit when r%NOTFOUND;
 end loop;
 close r;
end edit_coef;
END;
 
-- Erreur
Numéro de ligne = 19 Numéro de colonne = 15 Texte d'erreur = PLS-00597: l'expression 'R_COEF' dans la liste INTO est de type incorrect