Re: Problem updating a record

2013-12-03 Thread David G.P.
I would rather use '?' for the dates instead of concatenating them...


2013/12/3 Bob M rgmatth...@orcon.net.nz

 Thanks Myrna

 I can't tell you want happens as I have not run the code with a commit yet!

 Adding the one line psUpdate.executeUpdate(); is OK - thank you

 You are spot on with what I was assumingI did think that the
 update would only apply to the  last record in my table

 What I am trying to do is to update only the newest record in the table
 That record has the highest primary key which is made up of the first two
 fields in each record
 Field 1 = Date and Field 2 = Time (which has values 0, 6, 12, and 18)

 Are you suggesting that the following would suffice?

 psUpdate = conn.prepareStatement(Update USD_JPY SET Return_predicted=?,
 Class_predicted=? where Date= +Date1 +and Time= + Time1)

 A final question

 If one was inserting a new record using psInsert what code do you use to
 execute the Insert?

 Bob M



 --
 View this message in context:
 http://apache-database.10148.n7.nabble.com/Problem-updating-a-record-tp135856p135873.html
 Sent from the Apache Derby Users mailing list archive at Nabble.com.



Problems still in retrieving 'oldest' record and 'newest' record

2013-12-03 Thread Bob M
Hi again

My code currently does three transactions
1) updates the 'newest' record
2) inserts/appends a brand new record
3) deletes the 'oldest' record

Of these three only number 2 is working correctly

1) my code does NOT identify the 'newest' record correctly

3) my code does NOT identify the 'oldest' record correctly

My records use the first two fields as the unique key
The first field is a date field and the second is a time field [the second
only has 4 possible values 0, 6, 12, and 18]

My code for (1) above is as follows...
** 
// retrieve the last record from the table 
rs = s.executeQuery(SELECT * FROM USD_JPY ORDER BY Date DESC, Time DESC
FETCH FIRST ROW ONLY); 
rs.next(); 
String Date1 = rs.getString(Date); 
String Time1 = rs.getString(Time); 

myConsole.getOut().println(Latest record:- Date/Time:  + Date1 + ,  +
Time1); 

// Update this record by adding predicted return and predicted class 
psUpdate = conn.prepareStatement(UPDATE USD_JPY SET
Return_predicted=?,Class_predicted=? WHERE Date = ' + Date1 +' AND Time = 
 + Time1); 
statements.add(psUpdate); 

psUpdate.setDouble(1, return_current); 
psUpdate.setString(2, class_current); 
psUpdate.executeUpdate();

myConsole.getOut().println(Updated latest record with predicted return:  +
return_current + , predicted class:  + class_current); 

*** 

My code for (3) above is as follows...
** 
// retrieve and output date and time of oldest record from the table 
rs = s.executeQuery(SELECT * FROM USD_JPY ORDER BY Date ASC, Time ASC FETCH
FIRST ROW ONLY); 
rs.next(); 
String Date2 = rs.getString(Date); 
int Time2 = rs.getInt(Time); 

myConsole.getOut().println(Oldest record:- Date/Time:  + Date2 + ,  +
Time2); 

// and now delete this record. 

s.setCursorName(MYCURSOR); 
rs = s.executeQuery(SELECT * from USD_JPY WHERE Date = ' + Date2 + ' AND
Time =  + Time2 
+  FOR UPDATE); 
rs.next(); 
conn.prepareStatement(DELETE FROM USD_JPY WHERE CURRENT OF
MYCURSOR).executeUpdate(); 

myConsole.getOut().println(Deleted oldest record); 
*** 

The code shows the 'latest' record as 31-12-2010, 12 and the next one as
31-12-2010, 18
The code shows the 'oldest' record as 01-01-2010, 0 and the next one as
01-01-2010, 6

Any suggestions welcome

Bob M







--
View this message in context: 
http://apache-database.10148.n7.nabble.com/Problems-still-in-retrieving-oldest-record-and-newest-record-tp135875.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: A new Apache Derby pronunciation.

2013-12-03 Thread Rick Hillegas

On 11/30/13 6:49 AM, David G.P. wrote:

Hello all,

I am starting to use Derby for one project, and I just saw that you 
are collecting pronunciations of that sentence. I just recorded one 
with Spanish from Spain central-northern accent (Castilla-León). I 
can't edit the Wiki, so how can I contribute it?


Thanks for all your work and I hope I can contribute more soon.

Hi David,

The wiki has been locked down and this is the first request we've had 
from someone who wasn't included on the contributor whitelist. We need 
to add you to that whitelist. What's your contributor name?


Thanks,
-Rick


Re: A new Apache Derby pronunciation.

2013-12-03 Thread David G.P.
I registered with the name studiosi in the wiki.

Thanks!


2013/12/3 Rick Hillegas rick.hille...@oracle.com

 On 11/30/13 6:49 AM, David G.P. wrote:

 Hello all,

 I am starting to use Derby for one project, and I just saw that you are
 collecting pronunciations of that sentence. I just recorded one with
 Spanish from Spain central-northern accent (Castilla-León). I can't edit
 the Wiki, so how can I contribute it?

 Thanks for all your work and I hope I can contribute more soon.

 Hi David,

 The wiki has been locked down and this is the first request we've had from
 someone who wasn't included on the contributor whitelist. We need to add
 you to that whitelist. What's your contributor name?

 Thanks,
 -Rick