*
The moose likes JDBC and the fly likes select cum update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "select cum update" Watch "select cum update" New topic
Author

select cum update

raj baig
Ranch Hand

Joined: Jul 11, 2006
Posts: 96
hi guys,
How can i update the data while getting it.

i.e.
i am selecting the data from emp table , while getting only
i have to add 1000 to deptno=10

how can i?
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by raj baig:
How can i update the data while getting it.


Assume that you are looking UPDATE statement with SELECT to update records in a table based on another table or same table value.

SQL: UPDATE Statement

is this what you looking for?


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

You can perform an update into using a select, but I think he's talking about modifying the data coming from the select statement artibitrarily. In that case you have to create a new statement to the database an execute an UPDATE sql command separately from your SELECT query. That's the cleaner/better way to do it anyway.

For example, you may need to make changes to a dozen records, rather than 12 separate update calls, mark the records during the select you need to change and then update them all in a single update statement after all the records have been read.


My Blog: Down Home Country Coding with Scott Selikoff
raj baig
Ranch Hand

Joined: Jul 11, 2006
Posts: 96
Thank you Saif and Scott
raj baig
Ranch Hand

Joined: Jul 11, 2006
Posts: 96
Hi saif,
The links shows updating & selecting , but i want
selecting & updating.

suppose in my emp table deptno 10 employees sal =2000.

i want to get the employee information, while retrieve add 1000 to dept 10.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by raj baig:

but i want selecting & updating.



Scott Selikoff reply:
In that case you have to create a new statement to the database an execute an UPDATE sql command separately from your SELECT query. That's the cleaner/better way to do it anyway.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: select cum update
 
Similar Threads
update record for selection of id
URLyBird - Locking "Catch 22"
problem while running JUnit test cases through Hudson CI
In-Memory to On-Disk Database
jsp pop window