2012-09-11 9 views
9

Poniżej znajduje się kwerenda, którą otrzymuję, aby uzyskać aktualizacje w ciągu ostatniej godziny.Oracle aktualizuje dane w ciągu ostatniej godziny

select count(*) 
from my_table 
where last_updated_date between to_date(to_char(sysdate,'YYYY-MM-DD HH24'))-1/24 and to_date(to_char(sysdate,'YYYY-MM-DD HH24')); 

Nasz DB jest wyrocznią i się niepowodzeniem z

ORA-01861: literal does not match format string 
01861. 00000 - "literal does not match format string" 
*Cause: Literals in the input must be the same length as literals in 
      the format string (with the exception of leading whitespace). If the 
      "FX" modifier has been toggled on, the literal must match exactly, 
      with no extra whitespace. 
*Action: Correct the format string to match the literal. 

Co jest przyczyną tego błędu?

Odpowiedz

26

prostu odjąć 1/24 z SYSDATE aby uzyskać czas 1 godziny temu

select count(*) from my_table where last_updated_date >= (sysdate-1/24) 
Powiązane problemy