db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob M <rgmatth...@orcon.net.nz>
Subject Re: Retrieving the 'oldest' record and deleting it
Date Tue, 22 Oct 2013 17:40:13 GMT
Thanks Rick

Keeping the code 'in sync' is difficult when applying example code :)

Will the following do what I am seeking?

 rs = s.executeQuery("SELECT from tablename ORDER BY Date ASC, Time, ASC 
> FETCH FIRST ROW ONLY"); 
> rs.next(); 
> String Date = rs.getString("Date"); 
> String Date = rs.getString("Time"); 
> myConsole.getOut().println("Date/Time " + Date ", " + Time); 
> 
>
At this stage , I am successfully printing out the correct record data!

Now I wish to delete this record..........
 
         conn.setAutoCommit( false ); 

         s.setCursorName( "MYCURSOR" ); 
         rs = s.executeQuery( repeat the above...............); 
         rs.next(); 

         psDelete = conn.prepareStatement( "DELETE from tablename where
current of 
MYCURSOR" ); 
         statements.add(psDelete);     

} 

}


p.s.
code further above this lot................

ArrayList statements = new ArrayList();
PreparedStatement psInsert = null;
PreparedStatement psUpdate = null;
PreparedStatement psDelete  = null;
Statement s = null;
ResultSet rs = null;
 




--
View this message in context: http://apache-database.10148.n7.nabble.com/Retrieving-the-oldest-record-and-deleting-it-tp134915p134956.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

Mime
View raw message