Bonjour,
Je souhaite exécuter une requête oracle en utilisant des variables oracle pour des soucis de performance.
Code SAS d'origine (les dates sont des macro variables SAS) :
Code oracle à intégrer dans SAS (les dates deviennent des variables oracle) :
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 proc sql; connect to oracle(user=xxx orapw=xxx path=xxx); create table TMP_CALENDAR as select * from connection to oracle ( select CAL.CDDATE, upper(TYPE.SHORTNAME) as TYPE from CALENDAR_DATE CAL, CALENDAR TYPE where CAL.CALENDAR = TYPE.TID and ( CAL.VPCREATIONDATE <= to_date('25JAN2012:09:24:16','DDMONYYYY:HH24:MI:SS') ) and ( CAL.VPLASTUPDATE is null or CAL.VPLASTUPDATE >= to_date('25JAN2012:09:24:16','DDMONYYYY:HH24:MI:SS') ) and ( CAL.VPSTARTDATE is null or CAL.VPSTARTDATE <= to_date('15Nov2011:00:00:00','DDMONYYYY:HH24:MI:SS') ) and ( CAL.VPENDDATE is NULL or to_date('15Nov2011:00:00:00','DDMONYYYY:HH24:MI:SS') < CAL.VPENDDATE) and ( TYPE.VPCREATIONDATE <= to_date('25JAN2012:09:24:16','DDMONYYYY:HH24:MI:SS') ) and ( TYPE.VPLASTUPDATE is null or TYPE.VPLASTUPDATE >= to_date('25JAN2012:09:24:16','DDMONYYYY:HH24:MI:SS') ) and ( TYPE.VPSTARTDATE is null or TYPE.VPSTARTDATE <= to_date('15Nov2011:00:00:00','DDMONYYYY:HH24:MI:SS') ) and ( TYPE.VPENDDATE is NULL or to_date('15Nov2011:00:00:00','DDMONYYYY:HH24:MI:SS') < TYPE.VPENDDATE) ); disconnect from oracle; quit;
Merci d'avance pour votre aide.
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 VARIABLE date1 VARCHAR2(20); VARIABLE date2 VARCHAR2(20); exec :date1 := '25JAN2012:09:24:16' ; exec :date2 := '15Nov2011:00:00:00' ; select CAL.CDDATE, upper(TYPE.SHORTNAME) as TYPE from CALENDAR_DATE CAL, CALENDAR TYPE where CAL.CALENDAR = TYPE.TID and ( CAL.VPCREATIONDATE <= to_date(:date1,'DDMONYYYY:HH24:MI:SS') ) and ( CAL.VPLASTUPDATE is null or CAL.VPLASTUPDATE >= to_date(:date1,'DDMONYYYY:HH24:MI:SS') ) and ( CAL.VPSTARTDATE is null or CAL.VPSTARTDATE <= to_date(:date2,'DDMONYYYY:HH24:MI:SS') ) and ( CAL.VPENDDATE is NULL or to_date(:date2,'DDMONYYYY:HH24:MI:SS') < CAL.VPENDDATE) and ( TYPE.VPCREATIONDATE <= to_date(:date1,'DDMONYYYY:HH24:MI:SS') ) and ( TYPE.VPLASTUPDATE is null or TYPE.VPLASTUPDATE >= to_date(:date1,'DDMONYYYY:HH24:MI:SS') ) and ( TYPE.VPSTARTDATE is null or TYPE.VPSTARTDATE <= to_date(:date2,'DDMONYYYY:HH24:MI:SS') ) and ( TYPE.VPENDDATE is NULL or to_date(:date2,'DDMONYYYY:HH24:MI:SS') < TYPE.VPENDDATE)
Cordialement,
Mathilde.
Partager