plsql refacotiser les curseurs?
bonjour,
toujours dans la joie de millers de lignes plsql, je trouve dans les curseurs, d'horrible copier coller comme ceci.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
CURSOR c_sap004 (p_soort_tabel IN sap004.t04_soort_tabel%type) IS
SELECT t04.ROWID
, t04.t04_eind_stempel eindstempel
FROM sap004 t04
WHERE t04.t04_eind_stempel > SYSDATE
AND t04.t04_soort_tabel = p_soort_tabel
UNION
SELECT a.ROWID
, a.t04_eind_stempel
FROM sap004 a
WHERE t04_soort_tabel = p_soort_tabel
AND a.t04_eind_stempel = (SELECT b.t04_begin_stempel
FROM sap004 b
WHERE b.t04_eind_stempel > SYSDATE
AND b.t04_soort_tabel = a.t04_soort_tabel
AND b.t04_sector = a.t04_sector
AND b.t04_code = a.t04_code
AND b.t04_ingdat = a.t04_ingdat); |
et
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
CURSOR c_sap007 (p_soort_tabel IN sap007.t06_soort_tabel%type) IS
SELECT t06.ROWID
, t06.t06_eind_stempel eindstempel
FROM sap007 t06
WHERE t06.t06_eind_stempel > SYSDATE
AND t06.t06_soort_tabel = p_soort_tabel
UNION
SELECT a.ROWID
, a.t06_eind_stempel
FROM sap007 a
WHERE t06_soort_tabel = p_soort_tabel
AND a.t06_eind_stempel = (SELECT b.t06_begin_stempel
FROM sap007 b
WHERE b.t06_eind_stempel > SYSDATE
AND b.t06_soort_tabel = a.t06_soort_tabel
AND b.t06_sector = a.t06_sector
AND b.t06_code = a.t06_code
AND b.t06_ingdat = a.t06_ingdat); |
et
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
CURSOR c_sap003 (p_soort_tabel IN sap003.t03_soort_tabel%type) IS
SELECT t03.ROWID
, t03.t03_eind_stempel eindstempel
FROM sap003 t03
WHERE t03.t03_eind_stempel > SYSDATE
AND t03.t03_soort_tabel = p_soort_tabel
UNION
SELECT a.ROWID
, a.t03_eind_stempel
FROM sap003 a
WHERE t03_soort_tabel = p_soort_tabel
AND a.t03_eind_stempel = (SELECT b.t03_begin_stempel
FROM sap003 b
WHERE b.t03_eind_stempel > SYSDATE
AND b.t03_soort_tabel = a.t03_soort_tabel
AND b.t03_sector = a.t03_sector
AND b.t03_code = a.t03_code
AND b.t03_ingdat = a.t03_ingdat); |
comme on peut le voir il y a flagrand deli de copiage.
Est ce un defaut de language?? et on ne peut pas faire mieux ??
comment refactorier un truc pareil.??
y a t il un preprocesseur en plsql ou des templates ou des generics??
Y a t il en plsql un moyen de creer des commandes a la volée (en text) et puis de dire au moteur d'interpreter et d'executer ce text??
merci
a++