Any function available to parse delimiters in a column and give the fields
Posted in 2006
Topics: General Discussion
I have a string for eg: "12|A|B", and need a function that takes "|" as field delimeter and returns 2nd or say 3rd column. Is it possible to do this in informix. For Eg: If I ask for 2nd column I get "A". Also, is there a way to find a position of character in a string. For Eg: "ABCD" - C's position is 3.
One way would be to unload the table then use cut to get the fields you need. cat unloadfile | cut -d"|" -f 2,3 mohitanch...@gmail.com wrote: > I have a string for eg: "12|A|B", and need a function that takes "|" as > field delimeter and returns 2nd or say 3rd column. Is it possible to do > this in informix. For Eg: If I ask for 2nd column I get "A". > > Also, is there a way to find a position of character in a string. For > Eg: "ABCD" - C's position is 3.
mohitanchlia@gmail.com wrote: > I have a string for eg: "12|A|B", and need a function that takes "|" as > field delimeter and returns 2nd or say 3rd column. Is it possible to do > this in informix. For Eg: If I ask for 2nd column I get "A". > > Also, is there a way to find a position of character in a string. For > Eg: "ABCD" - C's position is 3. Your question needs some qualification: eg do you want to do that within - Informix 4gl? - Informix Dynamic Server? (I'll spare you the list of Informix products - but others may apply) You'll find you'll get different answers depending on what product you are referring to, and even what feature of the product -- Ciao, Marco ______________________________________________________________________________ Marco Greco /UK /IBM Standard disclaimers apply! Structured Query Scripting Language http://www.4glworks.com/sqsl.htm 4glworks http://www.4glworks.com Informix on Linux http://www.4glworks.com/ifmxlinux.htm
Marco Greco wrote:
> mohitanchlia@gmail.com wrote:
> > I have a string for eg: "12|A|B", and need a function that takes "|" as
> > field delimeter and returns 2nd or say 3rd column. Is it possible to do
> > this in informix. For Eg: If I ask for 2nd column I get "A".
> >
> > Also, is there a way to find a position of character in a string. For
> > Eg: "ABCD" - C's position is 3.
>
> Your question needs some qualification: eg do you want to do that within
> - Informix 4gl?
> - Informix Dynamic Server?
> (I'll spare you the list of Informix products - but others may apply)
>
> You'll find you'll get different answers depending on what product you are
> referring to, and even what feature of the product
> --
> Ciao,
> Marco
> ______________________________________________________________________________
> Marco Greco /UK /IBM Standard disclaimers apply!
>
> Structured Query Scripting Language http://www.4glworks.com/sqsl.htm
> 4glworks http://www.4glworks.com
> Informix on Linux http://www.4glworks.com/ifmxlinux.htm
I am not really a pro in informix, what I can tell is that I invoke
dbaccess and type SQL in there to execute it. I think it's informix
dynamic server (IDS) because I could use MULTISET which is part of IDS.
Please let me know how do I find out if you need to know. I think
Informix version is 9 40 FC7 (if this makes sense).