darc darc - 1 month ago 5
Java Question

How to add prefix string to sequence in oracle

Hi I want to create a sequence in oracle with prefix string. I know how to do this in

MSSQL 2008
but I am new to
oracle
.
Like below

ID
======
emp-1
emp-2


and so on

Answer
create or replace function getID return varchar2
is
  Val varchar2(50);
  begin 
  select 'Student-'||demoid.nextval into Val from dual;
  return Val;
end;

call this function

select getID() from dual
Comments