Bonjour,

Je dois faire une cartographie d'un univers BO.
A cet effet, j'ai pu récupérer l'ensemble des objets de celui-ci à partir du référentiel ORACLE.
Je souhaite maintenant énumérer la liste des tables et des colonnes associées. A cet effet, Je possède 2 colonnes contenant les clause SELECT et les clause WHERE. Chaque colonne peut bien sur contenir 1 ou plusieurs tables/colonne :

ex1 (le + simple) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
TP1_BB_CORRESP_CONTRAT.EXPGDF
Ex2 (plus compliqué):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
sum(TP1_BB_ECART_BILAN_ZT_M.ECRETEMENT_P1_M)
Ex3 (encore plus compliqué):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
CASE
          WHEN (S_BO_ECART_BILAN_A_JOUR.ID_ZONE_TARIF = 'ZT000B')
             THEN 'Zone Nord B'
          WHEN (S_BO_ECART_BILAN_A_JOUR.ID_ZONE_TARIF = 'ZT000N')
             THEN 'Zone Nord'
          WHEN (S_BO_ECART_BILAN_A_JOUR.ID_ZONE_TARIF = 'ZT000S')
             THEN 'Zone Sud'
       END
Ex 4 (aussi compliqué) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
sum(decode(TP1_BB_POINT_CONTRAT.DIRECTION_FLUX,S_BO_PROGRAMMATION_A_JOUR.SENS_NOMINATION,S_BO_PROGRAMMATION_A_JOUR.Q_PROGRAMMEE_M,(S_BO_PROGRAMMATION_A_JOUR.Q_PROGRAMMEE_M*(-1))))
Comme je dois reporter les définition de mes objet dans un dictionnaire central BO, il m'est impossible d'utiliser des fonctions PL/SQL; je dois donc tout faire en SQL natif.

J'ai commencé à utiliser les fonctions INSTR, TRANSLATE et SUBSTR, mais ma requête commence à ressembler à une véritable usine à gaz, car je dois coder en fonction du nombre de colonnes que je trouve (en l'occurence le nombre de point ('.') dans mon champ.
Et ça ne marche pas encore ...

voici un premier jet de ma requête :
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
select c.ch,
       (LENGTH(c.ch) - LENGTH(REPLACE(c.ch, '.', NULL))) as nb_occ,
       c.pos_point,
       instr(c.ch, '|', -pos_point, 1) pos_table,
       decode(0,
              instr(c.ch, '|', pos_point, 1),
              length(c.ch) - pos_point,
              instr(c.ch, '|', pos_point, 1) - pos_point - 1) as lg_champ,
       decode(0,
              instr(c.ch, '|', -pos_point, 1),
              pos_point - 1,
              pos_point - instr(c.ch, '|', -pos_point, 1) - 1) as lg_table
  from (select B.ch_a_analyser as ch,
               instr(b.ch_a_analyser, '.', 1, 1) as pos_point
          from (select a.obj_name,
                       a.obj_select,
                       LENGTH(obj_select) as lg,
                       translate(obj_select, '(),+-=>< ', '|||||||||') as ch_a_analyser,
                       (LENGTH(obj_select) -
                       LENGTH(REPLACE(obj_select, '.', NULL))) as nb_occ
                  from (SELECT UNV_CLASS.CLS_NAME,
                               UNV_OBJECT.OBJ_NAME,
                               object_tables.TAB_NAME,
                               object_select1.OBJ_DATAVALUE ||
                               object_select2.OBJ_DATAVALUE as obj_select,
                               object_where1.OBJ_DATAVALUE ||
                               object_where2.OBJ_DATAVALUE as obj_where
                          FROM UNV_CLASS,
                               UNV_OBJECT,
                               UNV_TABLE object_tables,
                               UNV_OBJECT_DATA object_select1,
                               UNV_OBJECT_DATA object_select2,
                               UNV_OBJECT_DATA object_where1,
                               UNV_OBJECT_DATA object_where2,
                               UNV_UNIVERSE,
                               UNV_OBJ_TAB
                         WHERE (UNV_CLASS.UNIVERSE_ID(+) =
                               UNV_UNIVERSE.UNIVERSE_ID)
                           AND (UNV_OBJECT.UNIVERSE_ID = UNV_CLASS.UNIVERSE_ID)
                           AND (UNV_OBJECT.CLASS_ID = UNV_CLASS.CLASS_ID)
                           AND (object_select1.OBJECT_ID(+) =
                               UNV_OBJECT.OBJECT_ID)
                           AND (object_select1.UNIVERSE_ID(+) =
                               UNV_OBJECT.UNIVERSE_ID)
                           AND (object_select2.UNIVERSE_ID(+) =
                               object_select1.UNIVERSE_ID)
                           AND (object_select2.OBJECT_ID(+) =
                               object_select1.OBJECT_ID)
                           AND (object_where1.UNIVERSE_ID(+) =
                               UNV_OBJECT.UNIVERSE_ID)
                           AND (object_where1.OBJECT_ID(+) =
                               UNV_OBJECT.OBJECT_ID)
                           AND (object_where2.UNIVERSE_ID(+) =
                               object_where1.UNIVERSE_ID)
                           AND (object_where2.OBJECT_ID(+) =
                               object_where1.OBJECT_ID)
                           AND (object_where1.OBJ_DATATYPE(+) = 'W')
                           AND (object_select1.OBJ_DATATYPE(+) = 'S')
                           AND (object_select2.OBJ_DATATYPE(+) = 'S')
                           AND (object_where2.OBJ_DATATYPE(+) = 'W')
                           AND (object_select1.OBJ_SLICE(+) = 1)
                           AND (object_where1.OBJ_SLICE(+) = 1)
                           AND (object_select2.OBJ_SLICE(+) = 2)
                           AND (object_where2.OBJ_SLICE(+) = 2)
                           AND (UNV_OBJ_TAB.UNIVERSE_ID(+) =
                               UNV_OBJECT.UNIVERSE_ID)
                           AND (UNV_OBJ_TAB.OBJECT_ID(+) =
                               UNV_OBJECT.OBJECT_ID)
                           AND (object_tables.UNIVERSE_ID(+) =
                               UNV_OBJ_TAB.UNIVERSE_ID)
                           AND (object_tables.TABLE_ID(+) =
                               UNV_OBJ_TAB.TABLE_ID)
                           AND (UNV_UNIVERSE.UNI_LONGNAME = 'BOBILAN')) a) b) C
Vous voyez déjà la complexité ... et encore, je ne traite que le cas ou je ne traite que le premier point, et dans ce cas ça ne marche pas si j'ai plusieurs points ...

Ne connaissant pas du tout l'utilisation des fonctions REGEXP, je voulais savoir si celles-ci sont adaptées à ma problématique, avant de me plonger dans une étude approfondie de celle-ci.

Merci d'avance pour vos réponses éclairées.