本文主要是介绍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 转mysql的newID()的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!