aspose file tools*
The moose likes JDBC and the fly likes Replacing name with first character in the DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Replacing name with first character in the DB" Watch "Replacing name with first character in the DB" New topic
Author

Replacing name with first character in the DB

vernon mweetwa
Greenhorn

Joined: Nov 26, 2004
Posts: 24
Hi all

i am trying to write a program that will query the database and thereafter update all the firstnames of the clients in the database to the first character of the firatname e.g a name in the database like vernon should now be v.this kind of a program should iterate through all the names in that database and update them accordingly.

what i need is the logic that will make the program to go to the first record of the database,check the firstname and update it,then move on to the next record,do the same until it reaches the last record.

waiting to hear from you soon.

[Bear edit: removed shouting from subject line; please note that you will find the caps lock key to the left of the A key]
[ January 17, 2005: Message edited by: Bear Bibeault ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Sounds like something with a database only solution, so I'm moving it to the JDBC forum.

Dave
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

waiting to hear from you soon.


You're unlikely to hear much with this type of question.

You'd get much better response by posting what work you have done so far, and asking questions about the aspects of it that are giving you trouble. You are unlikely to find someone willing to just write all the code for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
The following won't take the steps that you asked for (query, select names, iterate row-by-row, etc), but it has the same effect in the end. Oh, and it's Oracle-specific.Also, the second 1 in the substr call may need to be 2 if the end index is exclusive. I don't remember of the top of my head.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Replacing name with first character in the DB
 
Similar Threads
Inconsistency in DBAccess interface
update query
Some questions about data.java in Assignment
Reuse deleted record problem
Loading a large file into database