Re: Inserting and deleting records

2015-01-31 Thread Dyre Tjeldvoll
On 31. jan. 2015, at 13.50, Bob M rgmatth...@orcon.net.nz wrote: Hi Dyre Thank you for your explanation I understand completely My concept of requiring the table to look exactly as I think it should look before any ORDER BY is WRONG!!! Well, its an intuitive way to think

Re: Inserting and deleting records

2015-01-31 Thread Bob M
Thank you Dyre for a brilliant reply.. I do have a TRADE_ID number Also, I only ever have ONE open trade at any point in time I follow your three points completely Because I already have code which retrieves x records ordered by date and time I am considering the following code to

Re: Inserting and deleting records

2015-01-31 Thread Alex
Take a look at this example for deleting oldest record (adjust and test it!). I'm not sure if there's a cleaner way of doing this that Derby is capable of, probably someone on this list will point it out. DELETE FROM table1 WHERE CAST (due_date || ' ' || due_time AS TIMESTAMP) = (SELECT

Re: Inserting and deleting records

2015-01-31 Thread Alex
...sorry, that's would delete newest record (recordS, if there are several with identical date/time). Use MIN instead of MAX for oldest. /--Regards, Alex/ *From:* Me *Sent:* Saturday, January 31, 2015 11:55AM *To:* Derby

Re: Inserting and deleting records

2015-01-31 Thread Dyre Tjeldvoll
On 31. jan. 2015, at 14.59, Bob M rgmatth...@orcon.net.nz wrote: Thank you Dyre for a brilliant reply.. I do have a TRADE_ID number Also, I only ever have ONE open trade at any point in time I follow your three points completely Because I already have code which

Re: Inserting and deleting records

2015-01-31 Thread Bob M
Thanks Dyre If I choose to follow your No. 2 point to consider I set up the profit field with DEFAULT NULL There will only be one record at any point of time with the default value When I come to inserting a new record, do I need a line of code saying psInsert.setDouble(27,

Initializing a new record where field is NULL by default

2015-01-31 Thread Bob M
Hi When creating a new record, what does one need to code to initialize a field which you wish to have the default value of NULL? Bob M -- View this message in context: http://apache-database.10148.n7.nabble.com/Initializing-a-new-record-where-field-is-NULL-by-default-tp143732.html Sent from

Re: Inserting and deleting records

2015-01-31 Thread Dyre Tjeldvoll
See setNull http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#setNull(int,%20int) in the jdbc javadoc On 31. jan. 2015, at 18.58, Bob M rgmatth...@orcon.net.nz wrote: Thanks Dyre If I choose to follow your No. 2 point to consider I set up the

Re: Initializing a new record where field is NULL by default

2015-01-31 Thread Bob M
Hi Dyre I am still not grasping this. I have psInsert = conn.prepareStatement(INSERT INTO TABLE VALUES(?, ?.., ?) [27 of them] psInsert.setString(1, date); psInsert.setString(25, class); psInsert.setString(26, Trade_ID); but I am unclear what to put for the

Re: Initializing a new record where field is NULL by default

2015-01-31 Thread Dyre Tjeldvoll
On 31. jan. 2015, at 19.23, Bob M rgmatth...@orcon.net.nz wrote: Hi When creating a new record, what does one need to code to initialize a field which you wish to have the default value of NULL? See columnDefinition http://db.apache.org/derby/docs/10.11/ref/rrefsqlj30540.html in the

Re: Inserting and deleting records

2015-01-31 Thread Dyre Tjeldvoll
On 31. jan. 2015, at 08.27, Bob M rgmatth...@orcon.net.nz wrote: Hi I have a section of code which I hope does the following:- 1) inserts one new record with the latest (date + time) 2) deletes one old record with the oldest (date + time) When I run the code for example, I get 194 new

Re: Inserting and deleting records

2015-01-31 Thread Bob M
Hi Dyre Thank you for your explanation I understand completely My concept of requiring the table to look exactly as I think it should look before any ORDER BY is WRONG!!! I do, in fact, retrieve x records using ORDER BY exactly as you say to always get the x latest records. Now one