0

I have a field named end_time (of type timestamp(6)) in my Oracle 11g DB. My requirement is to fetch records which are greater than current time stamp.As I work with remote DB, I need the current time of my oracle database server.

After some research I came to know that SYSTIMESTAMP returns current time stamp of machine where DB resides.

So I just put a condition like end_time > SYSTIMESTAMP, but it does not filter records. My end-time is of type timestamp(6).

Do I have to use any conversion function? How can I do it from Hibernate? Any idea?

4

1 回答 1

0

您能否进一步解释“不过滤记录”,结果中的行太多还是太少?

你的情况看起来绝对没问题:

CREATE TABLE mytable (ts TIMESTAMP(6));
INSERT INTO mytable (ts) VALUES (TIMESTAMP '2012-12-06 17:00:00');
INSERT INTO mytable (ts) VALUES (TIMESTAMP '2012-12-06 18:00:00');

SELECT SYSTIMESTAMP FROM DUAL;
 06.12.2012 17:10:38.347629000 +01:00

SELECT * FROM mytable WHERE ts > SYSTIMESTAMP;
06.12.2012 18:00:00.000000000

SELECT * FROM mytable WHERE ts < SYSTIMESTAMP;
06.12.2012 17:00:00.000000000
于 2012-12-06T16:11:42.687 回答