前言:
而今姐妹们对“sql存储过程怎么写出来”大体比较讲究,小伙伴们都想要学习一些“sql存储过程怎么写出来”的相关文章。那么小编在网摘上网罗了一些有关“sql存储过程怎么写出来””的相关文章,希望小伙伴们能喜欢,你们一起来了解一下吧!创建 取决于工具==> ;(PB)或者go(Isql)
=====sybase=========
//创建(红色字体为创建关键字)
create procedure test
AS
BEGIN
//执行语句
select * from pl_term_ctl
END
;
//执行
exec test;
//删除
drop proc test;
或者 drop procedure test;
=====sybase=========
=====mysql=========
create procedure test()
BEGIN
select * from pl_term_ctl
END
;
//执行
call test;
//删除
drop procedure test;
=====mysql=========
==========例==============
create procedure test
as
begin
select pl_term_ctl.play_id, pl_term_ctl.term_code, pl_term_ctl.month_id, pl_term_ctl.term_begin_datetime, pl_term_ctl.term_end_datetime, pl_term_ctl.cancel_datetime, pl_term_ctl.raffle_flag, pl_term_ctl.encash_end_flag, pl_term_ctl.data_delete_flag, pl_term_ctl.day_dispose_flag, pl_term_ctl.term_dispose_flag, pl_term_ctl.rep_import_flag, pl_term_ctl.win_import_flag, pl_term_ctl.encash_length, pl_term_ctl.special_flag, pl_term_ctl.stat_term, pl_term_ctl.week_id, pl_term_ctl.thirdparty_flag, pl_term_ctl.luck_flag, pl_term_ctl.run_flag, pl_term_ctl.fee_return_mode from pl_term_ctl
end
;
===========================
===========简单示例=========
--sybase存储过程使用变量
#使用test库
use test;
#删除存储过程select_play
drop procedure select_play;
#创建存储过程select_play
#@play_cname varchar(10) 指定使用变量及其类型
create procedure select_play @play_cname varchar(10)
as
#简单查询语句
select play_id,play_cname,sp_flag,play_code from pl_play_inf
where play_cname like @play_cname+'%';
#传值调用
exec select_play '七';
标签: #sql存储过程怎么写出来 #存储过程的写法和使用方式