Erreur dans un package

mahni Messages postés 4 Date d'inscription samedi 15 juillet 2006 Statut Membre Dernière intervention 30 novembre 2007 - 30 nov. 2007 à 06:49
cs_exar Messages postés 286 Date d'inscription vendredi 5 décembre 2003 Statut Membre Dernière intervention 22 avril 2012 - 6 févr. 2009 à 14:47
bonjour , est-ce que quelqu'un pourrait m'aider à retrouver l'erreur dans le code que j'ai écrit ci-dessous! svp!
create or replace package exemple_package is 
    TYPE tab_t_rec_prog IS TABLE OF t_magasin%rowtype;      
    FUNCTION MesProg (p_i NUMBER) RETURN tab_t_rec_prog;
end exemple_package;

create or replace package body exemple_package is
FUNCTION MesProg(p_i NUMBER)  RETURN tab_t_rec_prog IS                      
cursor curs IS select *  from t_magasin;
TYPE t_rec IS TABLE OF t_magasin%rowtype;
i NUMBER := 1;
BEGIN
  FOR rec IN curs LOOP
    t_rec(i).mag_n_id := rec.mag_n_id;
    t_rec(i).mag_ch_nom := rec.mag_ch_nom;
    t_rec(i).mag_d_creation := rec.mag_d_creation;
    i := i+1;
  END LOOP;
  RETURN(t_rec(p_i));
END;
end exemple_package;

ERROR:Compilation errors for PACKAGE BODY FNAC.EXEMPLE_PACKAGE

Error: PLS-00306: numéro ou types d'arguments erronés dans appel à 'T_REC'
Line: 21
Text: t_rec(i).mag_n_id := rec.mag_n_id;

Error: PL/SQL: Statement ignored
Line: 21
Text: t_rec(i).mag_n_id := rec.mag_n_id;

Error: PLS-00306: numéro ou types d'arguments erronés dans appel à 'T_REC'
Line: 22
Text: t_rec(i).mag_ch_nom := rec.mag_ch_nom;

Error: PL/SQL: Statement ignored
Line: 22
Text: t_rec(i).mag_ch_nom := rec.mag_ch_nom;

Error: PLS-00306: numéro ou types d'arguments erronés dans appel à 'T_REC'
Line: 23
Text: t_rec(i).mag_d_creation := rec.mag_d_creation;

Error: PL/SQL: Statement ignored
Line: 23
Text: t_rec(i).mag_d_creation := rec.mag_d_creation;

Error: PLS-00306: numéro ou types d'arguments erronés dans appel à 'T_REC'
Line: 27
Text: RETURN(t_rec(p_i));

Error: PL/SQL: Statement ignored Line: 27 Text: RETURN(t_rec(p_i));

Merci
never be the same again

1 réponse

cs_exar Messages postés 286 Date d'inscription vendredi 5 décembre 2003 Statut Membre Dernière intervention 22 avril 2012 1
6 févr. 2009 à 14:47
type t_rec is t_magasin%rowtype;

FUNCTION MesProg(p_i NUMBER)  RETURN t_rec is
   rec t_rec;
BEGIN
   with tmp_query as (select rownum num, tm.* from t_magasin)
   select tm.mag_n_id, mag_ch_nom, mag_d_creation
      into rec.mag_n_id, rec.mag_ch_nom, rec.d_creation
    from tmp
  where num = p_i;

  return rec;

END;
0
Rejoignez-nous