problem in procedure [message #217126] |
Wed, 31 January 2007 14:58 |
kavi123
Messages: 13 Registered: January 2007
|
Junior Member |
|
|
Hi,
Iam working as an Oracle developer in Connecticut.I had a problem while writing a procedure in PL/SQL.I had a column father last name which in few records it was entered as MICHEAL JR,
JOHN,SR.
So now Iam trying to write a procedure through which my output can be in two seperate columns father last name and father generation id.
output:
Micheal JR
John SR
I have 657000 records in the table.
Please anyone kindly help me in doing this.
Thanku,
Have a great day,
Kavitha.
|
|
|
|
|
|
|
Re: problem in procedure [message #217342 is a reply to message #217190] |
Thu, 01 February 2007 14:54 |
Ericle
Messages: 44 Registered: April 2006 Location: United States of America ...
|
Member |
|
|
For the first column he could do
select initcap(substr(father_lastname,1,instr(father_lastname,' ')))||
substr(father_lastname,instr(father_lastname,' ')+1,
instr(father_lastname,',') - instr(father_lastname,' ')-1)
from big_table
That would give Micheal JR
He could use similar code for the other column to get the John SR output, but I have a headache and can't figure that out right now.
[Updated on: Thu, 01 February 2007 15:03] Report message to a moderator
|
|
|
Re: problem in procedure [message #217438 is a reply to message #217342] |
Fri, 02 February 2007 03:35 |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
1 SELECT replace(replace(initcap(father_lastname),'Jr','JR'),'Sr','SR')
2 From (select 'JOHN JR' father_lastname from dual union all
3* select 'JOHN SR' father_lastname from dual)
SQL> /
REPLACE(REPLACE(INITCAP(FATH
----------------------------
John JR
John SR
|
|
|
|