oracle 转mysql的newID()

前端之家收集整理的这篇文章主要介绍了oracle 转mysql的newID()前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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;


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;

猜你在找的Oracle相关文章