Subject | Re: How to make this (kind of a sort) inside a stored procedure? |
---|---|
Author | kurei_spin |
Post date | 2006-11-29T11:27:52Z |
Thanks for helping! Worked perfectly!!!
bye!
--- In firebird-support@yahoogroups.com, "Ivan Prenosil"
<Ivan.Prenosil@...> wrote:
bye!
--- In firebird-support@yahoogroups.com, "Ivan Prenosil"
<Ivan.Prenosil@...> wrote:
>have
> > Hi people! I've been trying to make a stored procedure where I
> > to move some strings inside an array. The first problem is thatI
> > can't use an array inside a stored procedure, right?together
>
> Isn't CHAR(5) the same as _array_ of 5 characters ?
>
>
> > So, I had to
> > create 5 varchar variables. These variables may have only two
> > values: 'T' or 'S'. And I want to make the 'T' values to be
> > in the order. Here's my code:THE
> ...
> > /*IF YOU TAKE A LOOK YOU'LL SEE THAT AFTER THAT I HAVE THE
> > FOLLOWING:*/
> > /*('T','T','S','T','S')*/
> > /*AND I WANT IT TO BE LIKE THIS:*/
> > /*('T','T','T','S','S')*/
> > /*SO, THE CODE MUST THROW THE 'S' TO THE RIGHT AND THE 'T' TO
> > LEFT*/this:
>
> If you really have only two values, you can try something like
>
> DECLARE VARIABLE ARRAY_IN VARCHAR(5);
> DECLARE VARIABLE ARRAY_OUT VARCHAR(5);
> BEGIN
> ARRAY_IN = 'TTSTS';
> ARRAY_OUT = '';
> WHILE (ARRAY_IN<>'') DO BEGIN
> IF (SUBSTRING(ARRAY_IN FROM 1 FOR 1) = 'T') THEN
> ARRAY_OUT = 'T' || ARRAY_OUT;
> ELSE
> ARRAY_OUT = ARRAY_OUT || 'S';
> ARRAY_IN = SUBSTRING(ARRAY_IN FROM 2 FOR 32767);
> END
> ...
> END
>
> Ivan
> http://www.volny.cz/iprenosil/interbase/
>