Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Question
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 ...
Any ideas?
TIA Randy Received on Fri Jun 10 2005 - 18:15:27 CDT
![]() |
![]() |