oracle:
CREATE OR REPLACE FUNCTION GET_HTBH
RETURN VARCHAR2IS
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;
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