>I'm trying to determine how (if possible without writing
>extension) to split a single column by a character value - for
>Column AgeRange has values such as 20-30, 40-50
>I'd like to do something like...
>select substr(agerange,1,instr(agerange,'-')-1) as StartAge,
>substr(agerange,instr(agerange,'-')+1) as EndAge
>I don't see an instr function supported in sqlite - any ideas?
>Get your own "800" number
>Voicemail, fax, email, and a lot more
I think you will have to write your own user defined function to do
this. The SQL standard defines a POSITION() function that returns the
position of one string within another, but sqlite doesn't implement it.
It should be fairly simple to provide your own function to do this. You
can look at the standard functions in func.c for some examples of using
the custom function API routines (the same routines are used to define
all the standard functions; sum, round, substr, etc.).
> If you're sure all the range strings are formatted
> correctly and if StartAge <= EndAge, you can do it
> with a case expression. The length of the range
> string will be >= 3 and <= 7; from the length you
> can deduce and hard code the indices in the substr