Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Oracle »

Job para modificar estado

Estas en el tema de Job para modificar estado en el foro de Oracle en Foros del Web. Hola. Me podrán ayudar? Tengo una tabla, la cual tiene los datos siguientes: ID_Reserva FCH_Reserva (timestamp) Estado Tengo claro lo que debo hacer, pero no ...
  #1 (permalink)  
Antiguo 04/02/2016, 08:24
 
Fecha de Ingreso: diciembre-2001
Ubicación: Peru
Mensajes: 376
Antigüedad: 22 años, 4 meses
Puntos: 0
Pregunta Job para modificar estado

Hola.
Me podrán ayudar?
Tengo una tabla, la cual tiene los datos siguientes:
ID_Reserva
FCH_Reserva (timestamp)
Estado
Tengo claro lo que debo hacer, pero no se como.
En FCH_Reserva se graba la fecha y la hora de la reserva y por defecto el ESTADO se graba como R (Reservado)
Quisiera hacer un Store el cual compare la fecha y hora actual con la grabada y si tiene mas de 24 horas y el estado aun es R, le cambie le estado a C (Cancelado)
Luego un job deberá ejecutar ese SP cada hora.


Estoy recien aprendiendo Oracle y no se como realizar esto.
Espero me puedan ayudar
Muchísimas gracias
  #2 (permalink)  
Antiguo 04/02/2016, 10:34
Avatar de huesos52
Colaborador
 
Fecha de Ingreso: febrero-2009
Ubicación: Manizales - Colombia
Mensajes: 5.980
Antigüedad: 15 años, 2 meses
Puntos: 360
Respuesta: Job para modificar estado

Hola Murallitz

Pon lo que lleves del codigo y tratamos de ayudarte en las dudas concretas que tengas.

Realmente, después de tener el procedimiento, ya es un tema de configuración hacer que un job lo ejecute.

Saludos
__________________
Without data, You are another person with an opinion.
W. Edwads Deming
  #3 (permalink)  
Antiguo 04/02/2016, 14:15
 
Fecha de Ingreso: diciembre-2001
Ubicación: Peru
Mensajes: 376
Antigüedad: 22 años, 4 meses
Puntos: 0
Respuesta: Job para modificar estado

Hola, como les comentaba, no se como hacer ni el job ni el SP.
Comencé por ver comparacion de fechas tipo timestamp y si la comparacion es mas de un día o 24 horas se cambiada el estado.
Pero trabajar con comparacion de timestamp no me funciona.
Saludos
  #4 (permalink)  
Antiguo 05/02/2016, 16:31
 
Fecha de Ingreso: diciembre-2001
Ubicación: Peru
Mensajes: 376
Antigüedad: 22 años, 4 meses
Puntos: 0
Respuesta: Job para modificar estado

Ya he creado el SP pero me sale un error:

Compilation errors for PROCEDURE INV.USP_MSC_MODIFICA_ESTADO

Error: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:

( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
continue avg count current exists max min prior sql stddev
sum variance execute forall merge time timestamp interval
date <a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternat
Line: 15
Text: UPDATE inv.tb_msc_reserva t

Error: PLS-00103: Encountered the symbol "@" when expecting one of the following:

( ) - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
table continue avg count current exists max min prior sql
stddev sum variance execute multiset the both leading
trailing forall merge year month day hour minute second
timezone_hour timezone_minute timezone_region timezone_abbr
time timestamp interval date
<a string literal with character set specification>
Line: 15
Text: UPDATE inv.tb_msc_reserva t

Error: PLS-00103: Encountered the symbol "=" when expecting one of the following:

. , @ ; for <an identifier>
<a double-quoted delimited-identifier> group having intersect
minus order partition start subpartition union where connect
sample
Line: 15
Text: UPDATE inv.tb_msc_reserva t




ESTE ES EL SP


CREATE OR REPLACE PROCEDURE "USP_MSC_MODIFICA_ESTADO"
AS
BEGIN
DECLARE CURSOR RESERVAR IS
SELECT ID_RESERVA,FCH_GRABACION FROM tb_msc_reserva
WHERE to_date(to_char(FCH_GRABACION,'dd/mm/yyyy')) = to_date(to_char(SYSDATE,'dd/mm/yyyy')) - 1;
id_reserva VARCHAR2(50);
fch_grabacion DATE;
BEGIN
OPEN RESERVAR;

FETCH RESERVAR INTO id_reserva, fch_grabacion;

IF SELECT TRUNC((SYSDATE) -TO_DATE(@FCH_GRABACION, 'DD/MM/YYYY HH24:MI:SS')) From DUAL=1 THEN

UPDATE inv.tb_msc_reserva t
SET t.flg_estado='C'
WHERE ID_Reserva=@ID_RESERVA;
COMMIT;
END IF ;
WHILE (@@FETCH_STATUS = 0)

CLOSE RESERVAR;

END;

Etiquetas: estado, job, modificar, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:34.