Archive for the 'Pl/SQL' Category

Jan 04 2007

Profile Image of mandymag
mandymag

PL/SQL concatenating names

Filed under Pl/SQL

To concat first name, middle name, and last name in Pl/SQL:

first_name_field||’ ‘||middle_name_field||’ ‘||last_name_field

 

To concat first name, middle initial, and last name do the following:

first_name_field||’ ‘||substr(middle_name_field,1,1)||’ ‘||last_name_field

 

If you want a period(.) and space after the folks who do have a middle initial/name and if you want no space or period if they do not have a middle initial/name:

first_name_field||’ ‘||
decode(substr(middle_name_field,1,1),null,”,substr(middle_name_field,1,1)||’. ‘)||last_name_field

 

I wrote that decode function all by myself without having to search on google or look at a pl/sql programming book. WOOT!

 

 

tags: , , , , , ,

2 responses so far

« Newer Posts - Older Posts »