Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Question

Re: Question

From: Rene Nyffenegger <rene.nyffenegger_at_gmx.ch>
Date: Fri, 10 Jun 2005 23:30:39 +0000 (UTC)
Message-ID: <d8d7qu$fvu$1@klatschtante.init7.net>


On 2005-06-10, WebTracer <randy_at_webtracersolutions.com> wrote:
> I am writing a PL/SQL Block to loop through a series of numbers and
> insert them into a row of my table ... but I need to change an alpha
> character while I am doing it.
>
> Here is my code:
>
> DECLARE
>
> v_Int VARCHAR2(2);
> v_Number VARCHAR2(2);
> v_Alpha VARCHAR2(2);
>
> BEGIN
>
> v_Alpha := 'A';
>
> LOOP
> v_Int := 1;
>
> LOOP
> v_Number := 1;
>
> LOOP
> INSERT INTO Table(CODE, LOCATION, DESCRIPTION) VALUES ('SMA',
> 'RCK'||v_Int||v_Alpha||'/BX'||v_Number, 'BLDG 91-05');
> v_Number := v_Number + 1;
>
> EXIT WHEN v_Number = 31;
> END LOOP;
>
> v_Int := v_Int +1;
>
> EXIT WHEN v_Int = 18;
> END LOOP;
>
> v_Alpha := ASCII(v_Alpha) + 1;
>
> EXIT WHEN v_Alpha = 'H';
> END LOOP;
>
> END;
>
> I have a feeling that the ASCII(v_Alpha) + 1 is not working the way I
> want it to ... I need to go from A to B then to C then to D etc ...

I don't understand what you want, but maybe you want v_Alpha := chr(ascii(v_Alpha)+1);

Anyway, why do you assign an integer to a varchar2?

And I have the feeling that this can be done with an SQL Statement.

Rene

-- 
  Rene Nyffenegger
  http://www.adp-gmbh.ch/
Received on Fri Jun 10 2005 - 18:30:39 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US