We are on Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi.
I'm needing to convert some SQL Server 2000 sql code to Oracle sql.
*** SQL Server Code
, CASE WHEN charindex(' ', RTRIM(SRV_NM)) > 1
THEN substring(RTRIM(SRV_NM), 1, charindex(' ', RTRIM(SRV_NM))-1)
ELSE RTRIM(SRV_NM)
END -- FIRST_NAME
, CASE WHEN charindex(' ', REVERSE(RTRIM(SRV_NM))) > 1
THEN RIGHT(RTRIM(SRV_NM), charindex(' ', REVERSE(RTRIM(SRV_NM)))-1)
END -- LAST_NAME
, CASE WHEN LEN(REPLACE(RTRIM(SRV_NM), SPACE(1), SPACE(0) )) < LEN(RTRIM(SRV_NM)) -1
THEN substring(RTRIM(SRV_NM), charindex(' ', RTRIM(SRV_NM)) + 1, LEN(RTRIM(SRV_NM)) -
charindex(' ', RTRIM(SRV_NM)) - charindex(SPACE(1), REVERSE(RTRIM(SRV_NM))))
END -- MIDDLE Name
Column SRV_NAME can be in these formats:
SRV_NAME
--------
Ella K. Cameron
Kenneth Chad Lambert
Results:
FIRST_NAME LAST_NAME MIDDLE_NAME
---------- ---------- ------------
Ella Cameron K.
Kenneth Lambert Chad
Any assistance appreciated.
Thank you.
I'm needing to convert some SQL Server 2000 sql code to Oracle sql.
*** SQL Server Code
, CASE WHEN charindex(' ', RTRIM(SRV_NM)) > 1
THEN substring(RTRIM(SRV_NM), 1, charindex(' ', RTRIM(SRV_NM))-1)
ELSE RTRIM(SRV_NM)
END -- FIRST_NAME
, CASE WHEN charindex(' ', REVERSE(RTRIM(SRV_NM))) > 1
THEN RIGHT(RTRIM(SRV_NM), charindex(' ', REVERSE(RTRIM(SRV_NM)))-1)
END -- LAST_NAME
, CASE WHEN LEN(REPLACE(RTRIM(SRV_NM), SPACE(1), SPACE(0) )) < LEN(RTRIM(SRV_NM)) -1
THEN substring(RTRIM(SRV_NM), charindex(' ', RTRIM(SRV_NM)) + 1, LEN(RTRIM(SRV_NM)) -
charindex(' ', RTRIM(SRV_NM)) - charindex(SPACE(1), REVERSE(RTRIM(SRV_NM))))
END -- MIDDLE Name
Column SRV_NAME can be in these formats:
SRV_NAME
--------
Ella K. Cameron
Kenneth Chad Lambert
Results:
FIRST_NAME LAST_NAME MIDDLE_NAME
---------- ---------- ------------
Ella Cameron K.
Kenneth Lambert Chad
Any assistance appreciated.
Thank you.