存储过程开发的具体步骤

一、编写存储过程

DELIMITER //           -- //代表分隔符

DROP PROCEDURE IFEXISTS proc_name; //

CREATE PROCEDUREproc_oper_art

(

    in i_is_auto integer,    --是否是自动创建标识   1:自动   0:手动

    in i_art_id  integer,    -- 文章ID

    out o_is_succ integer     -- 是否操作成功 0:成功   1:失败

)

begin

    declare v_createtime   datetime;         -- 文章创建时间,这个是带时分秒的

   

    -- 异常捕获

declareexit handler for sqlexception

begin

seto_is_succ = 1;

end;

 

--给年、月、日赋值

    set v_year = date_format(curdate(), '%Y');

   

    select a.creatime,                              -- into给变量是这样写的

   b.html_path,

           a.is_recoving,

           a.auto_create_cycle

      into v_createtime,

           v_path,

           v_is_recoving,

           v_cycle

      from cms_article a,

           cms_column b

     where a.col_id = b.id

       and a.id = i_art_id;

      

    -- 拼接path

setv_rel_path = concat(v_path, '/', v_day, '/', i_art_id, '.html');     -- 字符串拼接是用concat()

end;

//

 

二、测试存储过程

call proc_name();

上例中存储过程有in有out,调用时为

call proc_oper_art(1,2, @a);             -- out参数需要用@加变量

执行后可用select @a查询返回的结果


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值