Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / March 2006

Tip: Looking for answers? Try searching our database.

Limited rows update

Thread view: 
Khan - 25 Mar 2006 14:01 GMT
Hi,
    I'm using a table which has 100 rows. I want to update only 15
rows, i'm using stmt.executeUpdate("update sasuser.color set text =
'blue' where value = 'blue'");

with the above quary all 100 rows are updating coz all rows meet the
criteria, but i just want to update 15 rows. I used
stmt.setFetchSize(15); but not working.

Advise some solution.

Thanx.
Bill Karwin - 25 Mar 2006 21:03 GMT
> Hi,
>     I'm using a table which has 100 rows. I want to update only 15
[quoted text clipped - 3 lines]
> with the above quary all 100 rows are updating coz all rows meet the
> criteria, but i just want to update 15 rows.

Probably the best portable solution is to use a SELECT FOR UPDATE, and fetch
the first 15 rows of the SELECT (remember to explicitly use ORDER BY to make
sure you get the 15 rows you want).  Then perform a positioned UPDATE ...
WHERE CURRENT OF CURSOR <cursorname> on each row of the result set.

See the section 5.1.16 "Positioned Updates" here:
http://java.sun.com/j2se/1.5.0/docs/guide/jdbc/getstart/resultset.html
(or in docs of earlier versions of J2SE -- whichever one you use)

Regards,
Bill K.
scoffer - 27 Mar 2006 18:46 GMT
Hi,

wich database you have installed??

The syntax of this kind of query is dependant at the database you are using.

> Hi,
>     I'm using a table which has 100 rows. I want to update only 15
[quoted text clipped - 8 lines]
>
> Thanx.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.