473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Parsing the last name (from full name field) into temp table

How do I go about grabbing only the last name out of a 'Full Name' field ? I've so far tried executing a parse script in Oracle 9i using SQL Plus and am not successfully getting any data returned. Cannot find any references to the SQL scripts that will do this. Please help. All I need is just the basic SQL command and I can build on that. Thanks.
Bill
Mar 5 '07 #1
2 2759
vijaydiwakar
579 512MB
How do I go about grabbing only the last name out of a 'Full Name' field ? I've so far tried executing a parse script in Oracle 9i using SQL Plus and am not successfully getting any data returned. Cannot find any references to the SQL scripts that will do this. Please help. All I need is just the basic SQL command and I can build on that. Thanks.
Bill
try to use substr delimated by one space and use replace cmd to get the name only
Mar 6 '07 #2
Dave44
153 100+
How do I go about grabbing only the last name out of a 'Full Name' field ? I've so far tried executing a parse script in Oracle 9i using SQL Plus and am not successfully getting any data returned. Cannot find any references to the SQL scripts that will do this. Please help. All I need is just the basic SQL command and I can build on that. Thanks.
Bill

You can use something like this on it if it is delimited by a space:
Expand|Select|Wrap|Line Numbers
  1. [160]dave44@ORADB> DECLARE
  2.   2       full_name      VARCHAR2(30) := 'FName MName LName';
  3.   3       first_name     VARCHAR2(30);
  4.   4  BEGIN
  5.   5       first_name      := SUBSTR(full_name,0, INSTR(full_name, ' ', 1) );
  6.   6       DBMS_OUTPUT.put_line(first_name);
  7.   7  END;
  8.   8  /
  9. FName
  10.  
  11. PL/SQL procedure successfully completed.
  12.  
if it is delimited by something other than a space (' ') just change the parameter in the instr call

if it is in a different order in the table then you will have to play with what is here to get the correct field in the string.

Hope this helps.
Mar 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Andre | last post by:
I am needing to Parse some text fields, where a 3rd party application i use stores data from a user created expression. the user creates and expression such as this: ActualSizeYN =Y?...
3
by: Melissa | last post by:
I have this table: TblProjectYear ProjectYearID ProjectYearStartDate ProjectYearEndDate The Project Year will always span across December 31; for example 9/1/04 to 6/30/05. How do I build a...
5
by: LFM | last post by:
I have a table I'm importing from our SQL accounting database. The Employee Name is in one field. For the purpose of my needs, I need to extract the last name, first name and middle initial. ...
3
by: Aaron Walker | last post by:
At the beginning of my program, I open a config file and load the contents into a structure (please disregard the non-portable sockaddr_in struct as it is irrelevant to the problem): struct...
3
by: Mike | last post by:
Hi, I have three tables in the following structure (simplified): Table 1: Containing the customers ------------------------------------------------- create table Customers ( int...
1
by: DigitalPrankster | last post by:
I have a form that I am using to generate an email with several user selected fields being part of it. As part of this form, I have a select box which allows the user to select which email...
3
by: Damon Getsman | last post by:
Okay so I'm writing a script in python right now as a dirty fix for a problem we're having at work.. Unfortunately this is the first really non-trivial script that I've had to work with in python...
1
jkmyoung
by: jkmyoung | last post by:
Hi, can anyone point me to a function in MSSQL that returns the last index of a character in a string? I'm trying to find the base filename from a field that returns the full path. Eg. if db...
1
nine72
by: nine72 | last post by:
Ok, I am at a complete loss on this and have finally come to the XML Parsing Gods (and perhaps a PHP minor deity) for guidance… I will try my best to describe what I have going on… 1) I have 15...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.