Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: select separate values in a string: sql
Alex Doster wrote:
> Pardon me if this is the wrong group to ask this question to.
>
> I have a character field that contains address information
> (don't ask why I didn't seperate it)
> and I need to use pl/sql to grab individual parts of the string.
>
> Example - Field C_Address contains
>
> "1234 W. Value Street Denver, CO 99508"
>
> The query should return
> STREET 1234 W. Value Street
> CITY Denver
> STATE Colorado
> ZIPCODE 99508
>
>
> The only thing I can think of to get the zipcode is to use the right()
> function.
> SELECT RIGHT("C_ADDRESS", 5) AS ZIPCODE
> But am not sure if this will even work.
> Other than that, I'm stumped.
>
> Thanks for help
> Lex
Can you guarantee that addresses will always be in this format? If so,
then simple substr() and instr() commands will do the trick. However, if
any of the following might appear in the address line, you will need a
"smarter" parser:
This list is not all-inclusive ... but you generally can't get away with a simple parser to pick apart pieces of addresses. Back in my COBOL days, the USPS supplied a subroutine that would parse most US addresses. However, not even that was 100% accurate.
Good luck. Received on Tue Nov 19 2002 - 15:58:15 CST
![]() |
![]() |