Oracle 创建 newid()
函数
CREATE OR REPLACE FUNCTION "NEWID" RETURN VARCHAR2IS RESULT VARCHAR2 (40);BEGIN SELECT TO_CHAR (SYSDATE, 'yyyy') || TO_CHAR (SYSDATE, 'mm') || TO_CHAR (SYSDATE, 'dd') || TRIM (to_char(seq_public.NEXTVAL, '0000000000')) INTO RESULT FROM DUAL; --select '2006456456' into Result from dual; --Result := '2006123123'; RETURN (RESULT);END newid;
MySQL;
CREATE DEFINER = `zc`@`%` FUNCTION `NewPRoc`() RETURNS varchar(40)BEGIN REPLACE INTO `sys_sequence` (`stub`) VALUES ('a'); RETURN (select CONCAT((select DATE_FORMAT(NOW(),'%Y%m%d') from dual),LPAD((SELECT LAST_INSERT_ID()),10,'0')) from dual);END;
新闻热点
疑难解答