• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

set value in part of parameter

 
Steve Jiang
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have query like

select * from schedule where sched_time > sysdate and sched_time < sysdate + ?

How to set value for part of parameter, I use setFloat(1, timePeriod) and it is not working and return no rows in result set.

Any comments is appreciated.
 
Sri Vani Yama
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using setDate(), setTime() or setTimestamp() depening on the column type.
 
Steve Jiang
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the value I hope to fill is the time period. For example 1/4 as 6 hours/24 hours. I just need to input ? as the value of 1/4. how can I use setDate or setTimeStamp

select * from schedule where sched_time > sysdate and sched_time < sysdate + ?


with

select * from schedule where sched_time > sysdate and sched_time < sysdate + 1/4
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35269
383
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve,
The easiest way is to calculate the whole date in Java and pass it in.

Something like:

Then you have:

And can use setTimeStamp() on start and end.
 
Steve Jiang
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope combine the query as

select S.sched_time from schedule s,
(SELECT MAX(S.SCHED_START_DATE) START_TIME
FROM SCHEDULE S WHERE S.SCHED_START_DATE < SYSDATE
and id = 100 ) SS
where s.id = 100
and s.sched_time <= ss.start_date
and s.sched_time >= ss.start_date + ?

The direct query of below is working, but when I use setFloat(1, 1/2) is not working.

select S.sched_time from schedule s,
(SELECT MAX(S.SCHED_START_DATE) START_TIME
FROM SCHEDULE S WHERE S.SCHED_START_DATE < SYSDATE
and id = 100 ) SS
where s.id = 100
and s.sched_time <= ss.start_date
and s.sched_time >= ss.start_date + 1/2

Anyway to set value in this case?

Thanks,
[ August 10, 2005: Message edited by: Steve Jiang ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic