Hi,
You're not setting any qualifiers (WHERE) for UPDATE clause, so it
updates all records.
/--Regards, Alex/
*From:* Bob M rgmatth...@orcon.net.nz
*Sent:* Thursday, January 29, 2015 9:55AM
*To:* Derby Discussion
Hi
I now have the following code but NO update takes place???
psUpdate = conn.prepareStatement(update TABLE SET PROFIT_LOSS=? WHERE
PROFIT_LOSS=?);
Bob M
--
View this message in context:
On 29/01/2015 20:10, Bob M wrote:
Hi
I now have the following code but NO update takes place???
psUpdate = conn.prepareStatement(update TABLE SET PROFIT_LOSS=? WHERE
PROFIT_LOSS=?);
...which suggests that you have no rows whose PROFIT_LOSS column matches the
value of the second parameter.
Thank's John...
I now realise that when I create a new record I enter 0.00 into the
profit/loss field
I guess I should leave that field out when writing a new record and then
try your suggested code to update that 'blank' field
Bob M
--
View this message in context:
If I understand your initial question correctly, you want to use date as
a qualifier, not profit_loss.
You can do it in one statement like so (check carefully):
UPDATE TABLE SET PROFIT_LOSS=9000 WHERE DUE_DATE = (SELECT MAX(due_date)
from TABLE)
Also, take a look at how UPDATE and WHERE work
So..
Does the following code seem OK?
// Update Profit/Loss field
psUpdate = conn.prepareStatement(update TABLE SET PROFIT_LOSS=profit WHERE
(TRADING_DATE + TRADING_TIME) = (SELECT MAX(TRADING_DATE + TRADING_TIME)
from TABLE));
statements.add(psUpdate);
Hi Alex
Trying to understand all of this.
the qualifier I wish to use is a combination of two fields - date and time
[time is either 0, 6, 12, or 18 meaning hours]
Does 9000 in your coding suggestion mean blank?
So am I right in thinking
1) create new record by updating
I have tried the above code and get the following error..
SQL State: 42X04
Error Code: 2
Message: Column 'PROFIT' is either not in any table in the FROM list or
appears within a join specification and is outside the scope of the join
specification or appears in a HAVING clause