• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

set value in part of parameter

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic