Passer un tableau en paramètre d'une procédure
Bonjour,
J'ai déjà pas mal cherché sur ce sujet mais je sèche complètement.. Voici mon problème : j'ai un package, dont l'une des procédures a en argument un tableau.
Le code du package :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| create or replace PACKAGE my_cd_package IS
-- Déclaration d'un tableau
TYPE tab IS TABLE OF BB_TITRES.TIT_NOM%TYPE INDEX BY BINARY_INTEGER;
-- Etat du contenu de la table
PROCEDURE cdreport;
-- Procédure d'insertion d'artiste
PROCEDURE cdadd_art(nom VARCHAR);
-- Procédure d'insertion d'album (avec titres)
PROCEDURE cdadd_alb(nom VARCHAR, tabtitres IN my_cd_package.tab, art NUMBER, cat NUMBER);
-- Procédure d'insertion de catégorie
PROCEDURE cdadd_cat(nom VARCHAR);
-- Formulaire d'ajout
PROCEDURE cdform;
END my_cd_package; |
Le code du corps du package :
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
| create or replace PACKAGE BODY my_cd_package IS
PROCEDURE cdreport IS
CURSOR c1 IS SELECT CAT_NOM, alb.ALB_ID, ALB_NOM, ALB_PRIX, ART_NOM FROM BB_CATEGORIES cat, BB_ALBUMS alb, BB_ARTISTES art WHERE art.ART_ID=alb.ART_ID AND alb.CAT_ID=cat.CAT_ID;
CURSOR c2(id NUMBER) IS SELECT TIT_NOM FROM BB_TITRES tit WHERE tit.ALB_ID=id;
nom BB_TITRES.TIT_NOM%TYPE;
BEGIN
htp.htmlopen;
htp.headopen;
htp.htitle('Mon e-Shopping : résultats');
htp.headclose;
htp.bodyopen(cattributes => 'BGCOLOR="#FFF99"');
htp.br;
htp.print('<CENTER>');
htp.tableopen(cborder => 'BORDER="1"', cattributes => 'ALIGN="CENTER"');
htp.tableHeader('Catégorie', cattributes => 'BGCOLOR="#FF9900"');
htp.tableHeader('Artiste', cattributes => 'BGCOLOR="#FF9900"');
htp.tableHeader('Album', cattributes => 'BGCOLOR="#FF9900"');
htp.tableHeader('Prix', cattributes => 'BGCOLOR="#FF9900"');
htp.tableHeader('Titres', cattributes => 'BGCOLOR="#FF9900"');
FOR rec IN c1 LOOP
htp.tablerowopen;
htp.tabledata(rec.CAT_NOM);
htp.tabledata(rec.ART_NOM);
htp.tabledata(rec.ALB_NOM);
htp.tabledata(rec.ALB_PRIX);
if not (c2%ISOPEN) then
Open c2(rec.ALB_ID);
end if;
htp.print('<TD><TABLE width="auto" border=1>');
loop
fetch c2 into nom;
exit when c2%NOTFOUND or c2%ROWCOUNT=0;
htp.print('<TR><TD>');
htp.print(nom);
htp.print('</TD></TR>');
htp.tablerowopen;
end loop;
htp.print('</TABLE></TD>');
Close c2;
htp.tablerowclose;
END LOOP;
htp.tableclose;
htp.bodyclose;
htp.htmlclose;
END;
PROCEDURE cdadd_art(nom VARCHAR) IS
BEGIN
-- On ajoute la ligne
INSERT INTO BB_ARTISTES (ART_NOM) VALUES (nom);
COMMIT;
-- On redirige vers l'état final
owa_util.redirect_url(curl => 'my_cd_package.cdreport');
END;
PROCEDURE cdadd_cat(nom VARCHAR) IS
BEGIN
-- On ajoute la ligne
INSERT INTO BB_CATEGORIES (CAT_NOM) VALUES (nom);
COMMIT;
-- On redirige vers l'état final
owa_util.redirect_url(curl => 'my_cd_package.cdreport');
END;
PROCEDURE cdadd_alb(nom VARCHAR, tabtitres IN my_cd_package.tab, art NUMBER, cat NUMBER) IS
-- PROCEDURE cdadd_alb(nom VARCHAR, art NUMBER, cat NUMBER) IS
BEGIN
--dbms_output.put_line( tabtitres( tabtitres.first ) );
-- Pour chaque élément du tableau en paramètre, on ajoute un titre à l'album
-- et on associe l'album à un artiste et à une catégorie
/*
IF tabtitres.COUNT != 0 THEN
FOR i IN 1 .. tabtitres.COUNT LOOP
INSERT INTO BB_TITRES (TIT_NOM) VALUES (tabtitres(i));
COMMIT;
END LOOP;
END IF;
*/
COMMIT;
owa_util.redirect_url(curl => 'my_cd_package.cdreport');
END;
PROCEDURE cdform IS
BEGIN
htp.htmlopen;
htp.headopen;
htp.htitle('Mon e-Shopping : formulaire');
htp.headclose;
htp.bodyopen(cattributes => 'BGCOLOR="#FFF99"');
htp.br;
htp.print('<CENTER>');
htp.tableopen;
-- Ajout d'artiste
htp.tablerowopen;
htp.formopen(curl => 'my_cd_package.cdadd_art', cmethod => 'POST');
htp.tableopen(cborder => 'BORDER="1"');
htp.tablerowopen;
htp.tabledata(cvalue => 'Nom de l''artiste :');
htp.print('<TD>');
htp.formtext(cname => 'nom');
htp.print('<TD>');
htp.tablerowclose;
htp.tableclose;
htp.formsubmit;
htp.formclose;
htp.tablerowclose;
-- Ajout de catégorie
htp.tablerowopen;
htp.formopen(curl => 'my_cd_package.cdadd_cat', cmethod => 'POST');
htp.tableopen(cborder => 'BORDER="1"');
htp.tablerowopen;
htp.tabledata(cvalue => 'Nom de la catégorie :');
htp.print('<TD>');
htp.formtext(cname => 'nom');
htp.print('<TD>');
htp.tablerowclose;
htp.tableclose;
htp.formsubmit;
htp.formclose;
htp.tablerowclose;
htp.tableclose;
-- Ajout d'album
htp.tablerowopen;
htp.formopen(curl => 'my_cd_package.cdadd_alb', cmethod => 'POST');
htp.tableopen(cborder => 'BORDER="1"');
htp.tablerowopen;
htp.tabledata(cvalue => 'Nom de l''album :');
htp.print('<TD>');
htp.formtext(cname => 'nom');
htp.print('<TD>');
htp.tablerowclose;
/*
For i in 1..10
Loop
htp.tablerowopen;
htp.tabledata(cvalue => 'Titre :');
htp.print('<TD>');
htp.formtext(cname => 'tabtitres');
htp.print('<TD>');
htp.tablerowclose;
End loop ;
*/
htp.tablerowopen;
htp.tabledata(cvalue => 'ID de l''artiste :');
htp.print('<TD>');
htp.formtext(cname => 'art');
htp.print('<TD>');
htp.tablerowclose;
htp.tablerowopen;
htp.tabledata(cvalue => 'ID de la catégorie :');
htp.print('<TD>');
htp.formtext(cname => 'cat');
htp.print('<TD>');
htp.tablerowclose;
htp.tableclose;
htp.formsubmit;
htp.formclose;
htp.tablerowclose;
htp.tableclose;
htp.print('</CENTER>');
END;
END my_cd_package; |
La procédure qui pose problème est cdadd_alb. J'appelle ma procédure form dans mon navigateur, je remplis la partie du formulaire d'ajout d'album, et quand j'envoie, s'affiche l'erreur suivante : "The requested URL /hr/my_cd_package.cdadd_alb was not found on this server".
Quelqu'un aurait une idée ?
Merci beaucoup !