In PostgeSQL, I want to create inline functions like I have in other RDBMS'.
I want to be able to pass in a name field that has the format of: Last Name [space] optional Name Suffix, First Name[space] Middle Name and create 4 different inline functions that return each name part: 1. getFirstName(FullName), getMiddleName(FullName), getLastName(FullName), getNameSuffix(FullName)
The code would be something like this.
CREATE FUNCTION getFirstName(character varying) RETURNS character varying AS
[code to extract out First Name] LANGUAGE sql;
The use of the function would look something like this:
SELECT getFirstName('Smith Jr., Joseph F.' ) FROM emp;
Would return 'Joseph'
I have tried to created a function several times, but keep getting errors, please help with my syntax handicap! I am used to creating inline user defined functions for SQL Server 2000, but am struggling with PostgreSQL syntax differences when it comes to function syntax.