[Info-ingres] Help splitting up a varchar into pieces

twenty-six at b-mint.net twenty-six at b-mint.net
Wed Dec 3 08:24:09 UTC 2014


On 02/12/2014 11:43, Ingres Forums wrote:
> If there's a simple way to do this in Ingres, I'm struggling to think of
> it.
> Using a row producing procedure may be the best solution (see below).
> Cheers, GJ
>
> create table vtable(col1 varchar(10));
> insert into vtable
> values('abc123'),('ab1234'),('defgh45'),('a987654'),('dd3');
>
> create procedure rpproc(p varchar(10)) result row
> (varchar(10),varchar(10))=
> declare l=integer;
> begin
> l=0;
> while (l<length(p) and charextract(p,l+1) > '9')
> do
> l=l+1;
> endwhile;
> return row (left(p,l), right(p,length(p)-l));
> end;
>
> select v.col1,p.* from vtable v, rpproc(v.col1) p;
>
>
That looks a lot neater than my version,  I'll give it a try.  Thanks 
very much.



More information about the Info-ingres mailing list