db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex <alex3...@zoho.com>
Subject Re: Updating the last column in the newest record
Date Thu, 29 Jan 2015 20:24:06 GMT
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 in general:
http://www.postgresql.org/docs/9.4/interactive/dml-update.html
http://www.postgresql.org/docs/9.4/interactive/queries-table-expressions.html#QUERIES-WHERE

P.S. I tend to stay on SQL side of things as it is usually involves less 
boilerplate than JDBC. See for yourself if this works for you.

/--Regards, Alex/

------------------------------------------------------------------------

*From:* Bob M <rgmatthews@orcon.net.nz>
*Sent:* Thursday, January 29, 2015 9:10PM
*To:* Derby Discussion
*Subject:* Re: Updating the last column in the newest record
> 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: http://apache-database.10148.n7.nabble.com/Updating-the-last-column-in-the-newest-record-tp143710p143713.html
> Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message