RE: Increment an alphabetic variable in a PL/SQL loop?
Date: Thu, 3 Dec 2009 10:34:59 -0500
Message-ID: <D00A9309AEEDEC4387F2751F859B2101073434BE0E_at_us194mx002.tycoelectronics.net>
pretty much what folks are saying. My example may be overkill but hope it is helpful:
declare
letter char;
begin
for lcv in ascii('A')..ascii('Z') loop
letter := chr(lcv);
dbms_output.put_line('lcv is at ' || letter);
end loop;
end;
/
Replace dbms_output with your business logic. lcv has to be numeric.
From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of japplewhite_at_austinisd.org Sent: Thursday, December 03, 2009 10:28 AM To: 'Oracle-L_at_freelists.org'
Cc: ChrisDavid.Taylor_at_ingrambarge.com Subject: Re: Increment an alphabetic variable in a PL/SQL loop?
Chris,
Use the Chr(xx) function and increment the xx digit argument. Chr(65) = A, Chr(66) = B, and so on.
Jack C. Applewhite - Database Administrator
Austin I.S.D. - MIS Department
512.414.9715 (wk) / 512.935.5929 (pager)
From: "Taylor, Chris David" <ChrisDavid.Taylor_at_ingrambarge.com> To: "'Oracle-L_at_freelists.org'" <oracle-l_at_freelists.org> Date: 12/03/2009 09:22 AM
Subject: Increment an alphabetic variable in a PL/SQL loop? Sent by: oracle-l-bounce_at_freelists.org
________________________________
Hey how can we increment an alphabetic variable in PL/SQL?
Let's say I have var1 = 'A' for the first pass, but for the second pass, I want it to autoincrement to var1='B' and ultimately to 'Z'.
I'm searching but its hard to find the right search terms to give me what I want.
Chris Taylor
Sr. Oracle DBA
Ingram Barge Company
Nashville, TN 37205
Office: 615-517-3355
Cell: 615-354-4799
Email: chris.taylor_at_ingrambarge.com<mailto:chris.taylor_at_ingrambarge.com>
-- http://www.freelists.org/webpage/oracle-lReceived on Thu Dec 03 2009 - 09:34:59 CST