File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes select cum update Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply 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: 1318

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..
[Linkedin] How To Ask Questions On JavaRanch My OpenSource
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

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: 1318

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: select cum update
 
Similar Threads
In-Memory to On-Disk Database
problem while running JUnit test cases through Hudson CI
URLyBird - Locking "Catch 22"
jsp pop window
update record for selection of id