Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/10/2008, 03:09
josese
 
Fecha de Ingreso: diciembre-2006
Mensajes: 6
Antigüedad: 17 años, 4 meses
Puntos: 0
funcion para calcular la diferencia entre 2 fechas

Buenos dias, estoy intentando crear la funcion para que me devuelva la diferencia entre 2 timestamp pero me sale el siguiente error:

Error: java.sql.SQLException: ORA-06550: línea 2, columna 158:
PLS-00103: Se ha encontrado el símbolo "end-of-file" cuando se esperaba uno de los siguientes:

* & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
LIKE4_ LIKEC_ between overlaps || multiset year DAY_ member
SUBMULTISET_
, SQL State: 65000, Error Code: 6550
Error occured in:
begin
total_secs := (abs(extract(second from ts1-ts2) + extract(minute from ts1-ts2)*60 + extract(hour from ts1-ts2)*60*60 + extract(day from ts1-ts2)*24*60*60))

Ahora pego la funcion por si podeis echarle un ojo.

CREATE OR REPLACE function timestamp_diff_in_days (ts1 in timestamp, ts2 in timestamp)
return number
is
total_secs number;

begin
total_secs := (abs(extract(second from ts1-ts2) + extract(minute from ts1-ts2)*60 + extract(hour from ts1-ts2)*60*60 + extract(day from ts1-ts2)*24*60*60));
return total_secs;

end timestamp_diff_in_days;

Muchas gracias, un saludo.