$conn = OCILogon("turf", "oracle", "PCHS"); $query2 = "select count(*) from es_carreras where rn_hipodromo = 'C' and to_char(rn_fecha_reunion, 'ddmmyyyy') = to_char(sysdate, 'ddmmyyyy')" ; $stid2 = OCIParse($conn, $query2); OCIExecute($stid2, OCI_DEFAULT); while ($succ = OCIFetchInto($stid2, $row2)) { $tot = $row2[0]; } if ($tot == 0 ) { $query = "SELECT C.NUMERO_CARRERA, upper(replace(replace(E.COMBINACION, 'GRUPOS', ''),'GRUPO', '')), length(replace(replace(replace(E.COMBINACION,' ', ''), 'GRUPOS', ''),'GRUPO', '')), C.RN_NUMERO_REUNION, to_char(C.RN_FECHA_REUNION, 'dd/mm/yyyy') FROM TURF.ES_JUEGOS_SERIE E, es_carreras c where e.rn_fecha_reunion = (select max(rn_fecha_reunion) from es_resultados where rn_hipodromo = 'C') and e.combinacion like 'GRUPO%' and c.rn_hipodromo = e.rn_hipodromo and c.rn_numero_reunion = e.rn_numero_reunion and c.rn_fecha_reunion = e.rn_fecha_reunion and c.ev_numero_evento = e.ev_numero_evento and c.identificador_carrera = e.cr_identificador_carrera order by c.numero_carrera " ; } else { $query = "SELECT C.NUMERO_CARRERA, upper(replace(replace(E.COMBINACION, 'GRUPOS', ''),'GRUPO', '')), length(replace(replace(replace(E.COMBINACION,' ', ''), 'GRUPOS', ''),'GRUPO', '')), C.RN_NUMERO_REUNION, to_char(C.RN_FECHA_REUNION, 'dd/mm/yyyy') FROM TURF.ES_JUEGOS_SERIE E, es_carreras c where to_char(e.rn_fecha_reunion, 'ddmmyyyy') = to_char(sysdate, 'ddmmyyyy') and e.combinacion like 'GRUPO%' and c.rn_hipodromo = e.rn_hipodromo and c.rn_numero_reunion = e.rn_numero_reunion and c.rn_fecha_reunion = e.rn_fecha_reunion and c.ev_numero_evento = e.ev_numero_evento and c.identificador_carrera = e.cr_identificador_carrera order by c.numero_carrera " ; } $stid = OCIParse($conn, $query); OCIExecute($stid, OCI_DEFAULT); ?>