oracle 创建 newid()
CREATE OR REPLACE FUNCTION "NEWID"
RETURN VARCHAR2
IS
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;
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;
原文链接:https://www.f2er.com/oracle/210313.html