Insert d'instances définies par un "WITH SELECT"
Bonjour,
J'ai défini la requète suivante qui ramène les données attendues :
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
| SQL> desc actlist
Name Null? Type
----------------------------------------- -------- ----------------------------
TIME_ACT NOT NULL NUMBER(38)
NON_CTL_AREA_NAME NOT NULL VARCHAR2(12)
AIRSPACE_ENV_NAME NOT NULL VARCHAR2(20)
SQL> with sr AS
( select non_ctl_area_name,time_act as time_courant,
2 3 lead(time_act) over(partition by non_ctl_area_name order by time_act asc) as time_suivant
4 from actlist where airspace_env_name='MAASNEW' and non_ctl_area_name='NORB'
5 )
6 select non_ctl_area_name,time_courant,time_suivant
7 from sr
8 where time_suivant is not null;
NON_CTL_AREA TIME_COURANT TIME_SUIVANT
------------ ------------ ------------
NORB 1000 1100
NORB 1100 1200
NORB 1200 1300
NORB 1300 1400
SQL> |
J'ai besoin d'insérer les résultats dans une table afin de la réexploiter par d'autres requètes. J'ai testé la requète suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| SQL> desc time_tmp
Name Null? Type
----------------------------------------- -------- ----------------------------
NON_CTL_AREA_NAME NOT NULL VARCHAR2(12)
TIME_COURANT NOT NULL NUMBER(38)
TIME_SUIVANT NOT NULL NUMBER(38)
SQL> INSERT INTO TIME_TMP (
WITH SR AS (SELECT NON_CTL_AREA_NAME,TIME_ACT AS TIME_COURANT,
2 3 LEAD(TIME_ACT) OVER(PARTITION BY NON_CTL_AREA_NAME ORDER BY TIME_ACT ASC) AS TIME_SUIVANT
4 FROM ACTLIST
5 WHERE AIRSPACE_ENV_NAME = 'MAASNEW')
6 SELECT s.NON_CTL_AREA_NAME,s.TIME_COURANT,s.TIME_SUIVANT
7 FROM SR s
8 WHERE s.TIME_SUIVANT IS NOT NULL)
9 ;
WHERE s.TIME_SUIVANT IS NOT NULL)
*
ERROR at line 8:
ORA-32034: unsupported use of WITH clause |
Je ne sais pas trop comment formuler la requète, je compte sur les suggestions de la communauté.
Merci de votre aide