oracle 转mysql之函数替换

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

oracle:

CREATE OR REPLACE FUNCTION GET_HTBH

RETURN VARCHAR2
IS
RESULT VARCHAR2 (14);
BEGIN
SELECT TO_CHAR (SYSDATE,'yyyy')
|| TO_CHAR (SYSDATE,'mm')
|| TO_CHAR (SYSDATE,'dd')
|| TRIM (TO_CHAR (SEQ_HTBH.NEXTVAL,'000000'))
INTO RESULT
FROM DUAL;


--select '2006456456' into Result from dual;
--Result := '2006123123';
RETURN (RESULT);

END GET_HTBH;



MysqL


CREATE FUNCTION GET_HTBH()
RETURNS VARCHAR(14)
BEGIN
DECLARE RESULT VARCHAR(14);
select CONCAT((select DATE_FORMAT(NOW(),'%Y%m%d') from dual),LPAD((SEQ_HTBH()),6,'0'))
INTO RESULT
FROM DUAL;
-- select '2006456456' into Result from dual;
-- Result := '2006123123';
RETURN RESULT;
END;




MysqL注意事项 1 过程名要有( ) 2 end 不要过程名 3 没as 4DECLARE 要在begin下面 5 return 换成returns

原文链接:https://www.f2er.com/oracle/210402.html

猜你在找的Oracle相关文章