File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Replacing name with first character in the DB" Watch "Replacing name with first character in the DB" New topic

Replacing name with first character in the DB

vernon mweetwa

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

Joined: Mar 06, 2001
Posts: 13459

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

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63874

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] [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:
subject: Replacing name with first character in the DB
It's not a secret anymore!