ORACLE生成唯一标识函数

-- Create table
create table TAB_TEST
(
id VARCHAR2(40) not null,
fxnum VARCHAR2(40)
)

----------------------------------------------------------

create or replace function f_GetFxNum
return nvarchar2
as
FxNum nvarchar2(16);
begin
SELECT 'FX'||(NVL(MAX(SUBSTR(FxNum,3,14)),TO_CHAR(SYSDATE,'YYYYMMDD')||'000000')+1) into FxNum FROM TAB_TEST WHERE SUBSTR(FxNum,3,8)=TO_CHAR(SYSDATE,'YYYYMMDD') ;
return FxNum;
end;

 

-------------------------------------------------------------

select f_GetFxNum() from dual

posted @ 2017-01-18 10:07  落冰  阅读(4580)  评论(0编辑  收藏  举报