![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Aug 2005
Posts: 22
Rep Power: 0
![]() |
java, SQL, DB2
Not sure if anyone here will be able to offer help on these three combined but I'll see anyway.
I have a loop which looks like.. if (choice == 13)
{
String SQLStatement = "SELECT * FROM FlightBooking";
ResultSet rs = st.executeQuery(SQLStatement);
while(rs.next())
{
String bookingID = rs.getString("BookingID");
String SQLStatement3 = "UPDATE FlightBooking SET Duration = TIMESTAMPDIFF(8, CHAR(TIMESTAMP(CURRENT_TIMESTAMP)-TIMESTAMP((SELECT BookingTime FROM FlightBooking WHERE BookingID="+bookingID+"))))";
st.executeUpdate(SQLStatement3);
String bookingTime = rs.getString("BookingTime");
String duration = rs.getString("Duration");
System.out.println (bookingTime+" "+bookingID+" "+duration);
}
rs.close();
}with the problem lines in red. What I am attempting to do is execute an update each time through the loop based on the new value of bookingID. The error im getting is 'The statement did not return a results set'. Any thoughts?.... |
|
|
|
|
|
#2 |
|
Expert Programmer
|
It looks like your SQL query isn't returning any results. You should make sure your database contains the entries described by your query, or modify your query to reflect the contents of your database. You should also test that the results returned by your query are valid before attempting to work with them.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Aug 2005
Posts: 22
Rep Power: 0
![]() |
My query works at the Command editor, for individual rows, and I have data in the table, which is baffling me.
I'm trying to loop through to update the table for all rows. A single update seems to work fine. There must be other things to consider when using a loop. |
|
|
|
|
|
#4 |
|
Professional Programmer
|
Try : System.out.println (bookingID);
Maybe something's wrong there.
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|