Possible Duplicate:
is it possible to have alphanumeric sequence generator in sql
How to write a function in Oracle to generate a string like A0001, A0002, ..A9999,... AA0001, AA9999,... AZ0001, AZ9999,... for an employee id.
I started with this logic and but am able to generate only A001 to Z999:
CREATE OR REPLACE procedure GLOBALSHIFTER.p1 ( v1 in varchar2 default 'A') IS
id varchar2(4);
p1 number(2) := ascii(substr(v1,1,1));
p2 number(2);
p3 number(2) ;
c number(1) :=1;
begin
select s1.nextval into p2 from dual;
If p2 < 1000 then
id:= concat(chr(p1), lpad(p2,3,0));
ELSE
select s1.nextval into p2 from dual;
p1 := p1 + 1;
id := concat(chr(p1), lpad(p2,3,0));
END IF;
insert into t1 values(id);
commit;
end;