IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Oracle Discussion :

[PL/SQL] Collection


Sujet :

Oracle

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2004
    Messages
    104
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2004
    Messages : 104
    Points : 64
    Points
    64
    Par défaut [PL/SQL] Collection
    Bonjour,

    je cherche à faire une procédure PL/SQL qui me renvoit une collection pour afficher ensuite cette collection dans une page aspx.

    Il s'agirait d'une collection contenant 5 champs que j'alimenterai via des requetes. En fait une requete pour le premier champ et en fonction de la valeur de retour de ce champ, je dois faire des requetes différentes pour alimenter les autres champs.

    Comment faire cette collection???

  2. #2
    Membre actif
    Profil pro
    Inscrit en
    Avril 2004
    Messages
    422
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Avril 2004
    Messages : 422
    Points : 201
    Points
    201

  3. #3
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Jetez également un coup d'oeil à cet article
    http://sheikyerbouti.developpez.com/...record_set.htm
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2004
    Messages
    104
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2004
    Messages : 104
    Points : 64
    Points
    64
    Par défaut
    Mais quelle est la meilleure collection à utiliser pour mon cas

  5. #5
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Une table d'enregistrements me semble cohérent puisque vous ramenez 5 champs différents.
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2004
    Messages
    104
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2004
    Messages : 104
    Points : 64
    Points
    64
    Par défaut
    Donc si je fais ca, ca te semble cohérent :

    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
    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
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
     
    CREATE OR REPLACE PACKAGE PKG_TB IS
     
     
    -- Record --
    TYPE T_REC_ECO IS RECORD (
     libelleCTC Varchar2(20),
     resteCoupure INTEGER,
     stock INTEGER,
     traficTrie INTEGER,
     tauxReste number);
    -- Table de records --
    TYPE TAB_T_REC_ECO IS TABLE OF T_REC_ECO index by binary_integer ;
     
     
    PROCEDURE GetResteCoupureStock  (  PCI_CODE_CATEGORIE  IN CHAR,
                                       PNI_CODE_NIVEAU_TRI  IN NUMBER,
    								   PTO_RES OUT TAB_T_REC_ECO);
     
    END PKG_TB;
    /
     
    CREATE OR REPLACE PACKAGE BODY PKG_TB AS
     
     
    PROCEDURE GetResteCoupureStock  (  PCI_CODE_CATEGORIE  IN CHAR,
                                       PNI_CODE_NIVEAU_TRI IN NUMBER,
    								   PTO_RES OUT TAB_T_REC_ECO) IS
     
     
     
    codeCTC INTEGER;
    resteCoupure INTEGER;
    stock INTEGER;
    traficTrie INTEGER;
    fileHandler UTL_FILE.FILE_TYPE;
    indice INTEGER;
    codeZT INTEGER;
    traficTraite INTEGER;
    traficDefinitif INTEGER;
     
    -- Record --
    TYPE T_REC_ECO IS RECORD (
     libelleCTC Varchar2(20),
     resteCoupure INTEGER,
     stock INTEGER,
     traficTrie INTEGER,
     tauxReste number);
    -- Table de records --
    TYPE TAB_T_REC_ECO IS TABLE OF T_REC_ECO index by binary_integer ;
    t_rec TAB_T_REC_ECO ; -- variable tableau d'enregistrements
     
     
     BEGIN
     
        -- Ouverture du fichier de log
       fileHandler := UTL_FILE.FOPEN('TRC_DIR', 'eco_depart.log', 'w');
       stock := 0 ;
       resteCoupure := 0 ;
       traficTrie := 0;
       indice := 1;
     
       FOR r IN (
            -- recuperation de la liste des etablissement
            select distinct(ctc.code_ctc ),
                   ctc.libelle_ctc,
                   ctc.id_ctc
            from ctc, stock_etablissement se, stock_macro_pt smp
            where ctc.id_ctc = se.id_ctc
              and (smp.stock != 0 or smp.reste_en_coupure != 0)
              and smp.id_stock_etablissemen = se.id_stock_etablissemen
              and se.journee_postale = '15/11/2005'
              and ctc.date_suppression is null
              and se.date_suppression is null
     
       )
       LOOP
     
     
     
        UTL_FILE.PUT_LINE(fileHandler, 'code : ' || r.libelle_ctc);
        t_rec(indice).libelleCTC := r.libelle_ctc;
     
        for s in (
            select smp.reste_en_coupure,
                   smp.stock,
                   mp.id_macro_pt,
                   zt.code_zt
            from ctc, stock_etablissement se, stock_macro_pt smp, macro_pt mp, categorie cat, niveau_tri nt, zt
            where ctc.id_ctc = se.id_ctc
              and (smp.stock != 0 or smp.reste_en_coupure != 0)
              and smp.id_stock_etablissemen = se.id_stock_etablissemen
              and se.journee_postale = '15/11/2005'
              and mp.id_macro_pt = smp.id_macro_pt
              and mp.id_categorie = cat.id_categorie
              and mp.id_niveau_tri = nt.id_niveau_tri
              and cat.code_categorie = PCI_CODE_CATEGORIE
              and nt.code_nt = PNI_CODE_NIVEAU_TRI
              and ctc.date_suppression is null
              and se.date_suppression is null
              and mp.date_suppression is null
              and cat.date_suppression is null
              and nt.date_suppression is null
              and ctc.id_ctc = r.id_ctc
              and zt.id_zt = mp.id_zt
     
        )
        LOOP
     
            resteCoupure := resteCoupure + s.reste_en_coupure;
            stock := stock + s.stock;
             UTL_FILE.PUT_LINE(fileHandler, 'macrpt : ' || s.id_macro_pt);
             UTL_FILE.PUT_LINE(fileHandler, 'code zt : ' || s.code_zt);
     
     
     
        -- recuperation trafic trié
     
        if (s.code_zt = '2') then
     
          select sum(t.trafic_traite) into traficTraite
          from  macro_pt mp, categorie cat, niveau_tri nt, chaine ch, trafic t, zt
          where cat.date_suppression is null
            and nt.date_suppression is null
            and zt.date_suppression is null
            and t.date_suppression is null
            and mp.id_macro_pt = s.id_macro_pt
            and mp.id_categorie = cat.id_categorie
            and mp.id_niveau_tri = nt.id_niveau_tri
            and cat.code_categorie = PCI_CODE_CATEGORIE
            and nt.code_nt = PNI_CODE_NIVEAU_TRI
            and ch.id_macro_pt = s.id_macro_pt
            and t.id_chaine = ch.id_chaine
            and t.journee_postale = '15/11/2005'
            and zt.id_zt = mp.id_zt
            and zt.code_zt = 2;
     
          if traficTraite > 0 then
             traficTrie := traficTrie + traficTraite;
          end if;
     
           UTL_FILE.PUT_LINE(fileHandler, 'traficTraite : ' || traficTraite);
        end if;
     
        if   (s.code_zt = 1)  then
     
          select sum(trafic_definitif) into traficDefinitif
          from ctc, stock_etablissement se, stock_macro_pt smp, macro_pt mp, categorie cat, niveau_tri nt, chaine ch, trafic t, zt
          where cat.date_suppression is null
            and nt.date_suppression is null
            and zt.date_suppression is null
            and t.date_suppression is null
            and mp.id_macro_pt = s.id_macro_pt
            and mp.id_categorie = cat.id_categorie
            and mp.id_niveau_tri = nt.id_niveau_tri
            and cat.code_categorie = PCI_CODE_CATEGORIE
            and nt.code_nt = PNI_CODE_NIVEAU_TRI
            and ch.id_macro_pt = s.id_macro_pt
            and t.id_chaine = ch.id_chaine
            and t.journee_postale = '15/11/2005'
            and zt.id_zt = mp.id_zt
            and zt.code_zt = 1;
     
     
          UTL_FILE.PUT_LINE(fileHandler, 'traficDefinitif : ' || traficDefinitif);
     
          if traficDefinitif > 0 then
             traficTrie := traficTrie + traficDefinitif;
          end if;
     
         end if;
     
        END LOOP;
     
     
        t_rec(indice).resteCoupure := resteCoupure;
        t_rec(indice).stock := stock;
        t_rec(indice).traficTrie := traficTrie;
     
        if traficTrie != 0 then
           t_rec(indice).tauxReste := stock / traficTrie;
        end if;
     
         UTL_FILE.PUT_LINE(fileHandler, 'reste : ' || resteCoupure);
         UTL_FILE.PUT_LINE(fileHandler, 'stock : ' || stock);
        UTL_FILE.PUT_LINE(fileHandler, 'traficTrie : ' || traficTrie);
        UTL_FILE.PUT_LINE(fileHandler, 'tauxReste : ' || t_rec(indice).tauxReste);
        indice := indice + 1;
     
       END LOOP;
     
      -- PTO_RES :=t_rec;
     
       -- Fermeture du fichier de log
       UTL_FILE.FCLOSE(fileHandler);
     
     
     
     EXCEPTION
       WHEN utl_file.invalid_path THEN
         RAISE_APPLICATION_ERROR(-20000, 'Erreur: répertoire / nom de fichier invalide');
       WHEN OTHERS THEN
          RAISE;
     
     
     
     
    END GetResteCoupureStock;
    END PKG_TB;
    /

  7. #7
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Les types définis dans la partie spécification du package n'ont pas besoin d'être re-définis dans la partie corps
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  8. #8
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2004
    Messages
    104
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2004
    Messages : 104
    Points : 64
    Points
    64
    Par défaut
    MERCI DE L'INFO

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. PL SQL Collection optimisation
    Par nathieb dans le forum PL/SQL
    Réponses: 8
    Dernier message: 04/11/2008, 14h13
  2. [Linq To Sql]Collection de schémas XML
    Par binoo dans le forum Accès aux données
    Réponses: 7
    Dernier message: 23/05/2008, 09h14
  3. Réponses: 1
    Dernier message: 17/03/2006, 07h21
  4. [9i][pl/sql] Dedoublonage d une collection
    Par MorganeD dans le forum Oracle
    Réponses: 8
    Dernier message: 20/09/2005, 17h38
  5. [PL/SQL] Charger une table dans une collection
    Par nosnoss dans le forum Oracle
    Réponses: 10
    Dernier message: 03/03/2005, 17h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo