-- Create sequence create sequence SEQU_SOFA_FID minvalue 1 maxvalue 99999 start with 7 increment by 1 cache 100 cycle; CREATE OR REPLACE FUNCTION SOFA_NUID RETURN NUMBER IS RE NUMBER(20); BEGIN SELECT TO_NUMBER(TO_CHAR(SYSDATE,'YYMMDDhh24miSS') || LPAD(ABS(MOD(DBMS_RANDOM.RANDOM,1000)),3,0) || LPAD(SEQU_SOFA_FID.NEXTVAL,5,0)) INTO RE FROM DUAL; RETURN RE; END;