[SQL] Timestamp et interval
Bonjour à tous.
J'essaye de créer une requête insert basée sur un select avec des datatype timestamp et y ajouter des interval.
Le simple select fonctionne.
Mais une fois que construit l'insert basé sur ce sélect, ça foire.
Le problème vient de l'intervalle.
Je sais c'est surement tout con mais je trouve pas.
Voici la DDL (table et séquence) de la table
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
| REM START EPSS EPSS_MONITOR
CREATE TABLE "EPSS"."EPSS_MONITOR"
( "ID" NUMBER,
"START_TIME" TIMESTAMP (6),
"END_TIME" TIMESTAMP (6),
"DESCRIPTION" VARCHAR2(200 CHAR),
"TIME_SPENT" NUMBER,
"CHECK_OK" VARCHAR2(20 CHAR)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "EPSS_DATA" ;
REM END EPSS EPSS_MONITOR
REM START EPSS EPSS_MONITOR
COMMENT ON TABLE "EPSS"."EPSS_MONITOR" IS 'used internally to store the time spent by the monitoring station to submit a proposal without taking into account the network load.';
REM END EPSS EPSS_MONITOR
REM START EPSS EPSS_MONITOR_INDEX
CREATE UNIQUE INDEX "EPSS"."EPSS_MONITOR_INDEX" ON "EPSS"."EPSS_MONITOR" ("ID")
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "EPSS_INDEX" ;
REM END EPSS EPSS_MONITOR_INDEX
The sequence:
REM START EPSS EPSS_PERFMON
CREATE SEQUENCE "EPSS"."EPSS_PERFMON" MINVALUE 1 MAXVALUE 99999999999 INCREMENT BY 1 START WITH 116934 CACHE 20 ORDER NOCYCLE ;
REM END EPSS EPSS_PERFMON |
Et voici la requête:
Code:
1 2 3 4 5 6 7
| select
'insert into epss_monitor (id, start_time, end_time, description, time_spent, check_ok)
values (epss_perfmon.nextval, timestamp '''||start_time + interval '''1''' month ||''', timestamp '''||end_time + interval '''1''' month ||''','||description||','|| time_spent||','||check_ok||');'
from epss_monitor
where start_time
between to_timestamp ('08-02-2008 09:14:00' ,'DD-MM-YYYY HH24:MI:SS')
and to_timestamp ('10-02-2008 10:31:00','DD-MM-YYYY HH24:MI:SS') order by start_time |
Le problème survient ici:
Code:
start_time + interval '''1''' month
C'est certainement un problème de single quotes. Mais je trouve pas :evilred:
Voilà.
Merci d'avance pour vos réponses. :wink: