Link to home
Start Free TrialLog in
Avatar of reddi_mk
reddi_mk

asked on

alphabetic sequence generation in oracle

I need unique alphabeticals sequence generation for about 5000 in oracle, how do I do that
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

could you please clarify the request?
Avatar of reddi_mk
reddi_mk

ASKER

I need to generate unique alphabeticals like A B C...Z , AA AB AB...AZ, BA,BB,BC...BZ  up to 5 characters
Could you please send me the script for this.
I need this in pl/sql script.
i had following script can somebody tweak it.

declare
v_Current_Number number;
v_Current_Mod_Value number;
v_Current_Quot_Value number;
v_third_char varchar2(200);
v_second_char varchar2(200);
v_first_char varchar2(200);
v_Final_String varchar2(200);
     begin
select CINXFER.Testseq.nextval into v_Current_Number from dual;
v_Current_Mod_Value := mod(v_Current_Number, 26);
v_Current_Quot_Value := trunc(v_Current_Number/26);
select chr(64+ decode(v_Current_Mod_Value, 0, 26, v_Current_Mod_Value)) into v_third_char from dual;
dbms_output.put_line('third_char '||v_third_char);
select decode(v_Current_Quot_Value, 0, NULL,chr(64+ decode(mod(v_Current_Quot_Value, 26), 0, 26, mod(v_Current_Quot_Value, 26)))) into v_second_char from dual;
select decode(trunc(v_Current_Number/(26*26)), 0, NULL, chr(64+ decode(mod(trunc(v_Current_Number/(26*26)), 26), 0, 26, mod(trunc(v_Current_Number/(26*26)), 26)))) into v_first_char from dual;
v_Final_String := v_first_char||v_second_char||v_third_char;
end;

Open in new window

Can somebody help me I need to get this done by end of today.
ASKER CERTIFIED SOLUTION
Avatar of DiscoNova
DiscoNova
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i strongly object the fact that users have, during the last couple of months, started to abuse EE's "request removal"-option instead of awarding points to the people responding to their questions.

The page I linked to gives not only one, but a multitude of distinct possibilities of solving the problem. All the author needed to do is choose the one that suits him best.