码迷,mamicode.com
首页 > 其他好文 > 详细

存储过程和函数

时间:2016-01-08 18:39:00      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

DROP PROCEDURE PROC_Z4;

CREATE PROCEDURE proc_z4()
BEGIN
    DECLARE card CHAR(20);    
    DECLARE count INT;
    SELECT count(*) INTO count FROM Z4;    
    BEGIN
        DECLARE cur CURSOR FOR SELECT card FROM Z4;
        OPEN cur;
        WHILE count>0 do    
            FETCH cur INTO card;
            IF card=100 then
                INSERT INTO z3(card) VALUES(card);
            END IF;
            SET count=count-1;    
        END WHILE;
        CLOSE cur;
    END;    
END;

DROP FUNCTION FUN_WJF;
CREATE FUNCTION fun_wjf(c CHAR(20))
RETURNs CHAR(20)
LANGUAGE SQL
BEGIN ATOMIC
    RETURN rtrim(c)||a;
END
CREATE FUNCTION fun_wjf(c CHAR(20))
RETURNs CHAR(20)
LANGUAGE SQL
BEGIN ATOMIC
    RETURN rtrim(c)||a;
END
SELECT fun_wjf(CARD), TRCD, AMOUNT FROM z3;

 

存储过程和函数

标签:

原文地址:http://www.cnblogs.com/wujf/p/5113962.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!