Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide functions to parse delimited strings [CORE3322] #3689

Open
firebird-automations opened this issue Jan 31, 2011 · 2 comments
Open

Provide functions to parse delimited strings [CORE3322] #3689

firebird-automations opened this issue Jan 31, 2011 · 2 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

It's often need to parse some string with known delimeters and obtain:
1) count of tokens inside input string
2) get token by it's number.
Examples:

str = 'aaa,,,....,,bbb,;.;'';;ccc''', delimeters = '.;:,' || asci_char(39)
count of tokens ==> 3
token #⁠1 ==> 'aaa'
token #⁠2 ==> 'bbb'
token #⁠3 ==> 'ccc'

So, the function calls could be like these:

select token_count(:str), token_get(:str, 2)
from rdb$database; -- returns 3 in 1st column and 'bbb' in 2nd

Is it possible to provide in FB 2.5.x two functions that can returns such results ? Currently developer have to use UDFs or SP with loop (i.e. cursor) or recursive CTE to get such simple data.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

summary: provive functions to parse string with delimeters => Provide functions to parse delimited strings

Version: 2.5.0 [ 10221 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

description: It's often need to parse some string with known delimeters and obtain:
1) count of tokens inside input string
2) get token by it's name.
Examples:

str = 'aaa,,,....,,bbb,;.;'';;ccc''', delimeters = '.;:,' || asci_char(39)
count of tokens ==> 3
token #⁠1 ==> 'aaa'
token #⁠2 ==> 'bbb'
token #⁠3 ==> 'ccc'

Is it possible to provide in FB 2.5.x two functions that can returns such results ? Currently developer have to use UDFs or SP with loop (i.e. cursor) or recursive CTE to get such simple data.

=>

It's often need to parse some string with known delimeters and obtain:
1) count of tokens inside input string
2) get token by it's number.
Examples:

str = 'aaa,,,....,,bbb,;.;'';;ccc''', delimeters = '.;:,' || asci_char(39)
count of tokens ==> 3
token #⁠1 ==> 'aaa'
token #⁠2 ==> 'bbb'
token #⁠3 ==> 'ccc'

So, the function calls could be like these:

select token_count(:str), token_get(:str, 2)
from rdb$database; -- returns 3 in 1st column and 'bbb' in 2nd

Is it possible to provide in FB 2.5.x two functions that can returns such results ? Currently developer have to use UDFs or SP with loop (i.e. cursor) or recursive CTE to get such simple data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant