CREATE PROCEDURE `pr_sel`(
in Input_uid int
declare userid int;
if userid is null then
set userid = 0;
end if;
set userid = Input_uid;
/*查询该用户*/
select * from user where user_id=userid;
/*查询该用户的billing*/
select * from Billing where user_id=userid;
/*查询改用户的会议*/
select * from Conference where author_id=userid;
/*查询改用户Comment*/
select * from Comment where author_id=userid;
/*查询该用户的billing*/
select * from OauthInfo where uid=userid;
/*查询该用户的Feedback*/
select * from Feedback where uid=userid;
/*查询该用户的UserInventory*/
select * from UserInventory where user_id=userid;
/*查询该用户的Deposit*/
select * from Deposit where user_id=userid;
/*查询该用户的Invoice*/
select * from Invoice where user_id=userid;
/*查询该用户的Orders*/
select * from Orders where user_id=userid;
/*查询该用户的Transaction*/
select * from Transaction where user_id=userid;
end;
in Input_uid int
)
创建存储过程的指令,括号内的是存储过程的参数定义,参数可以分为三类:
“in”、“out”、“inout”,则默认为“in”,习惯上,对于是“in” 的参数,都不会显式指定。
注:MySQL 存储过程参数,不能在参数名称前加“@”,如:“@a int”。
下面是执行的sql语句,需要从begin开始,end结束:
declare userid int;
if userid is null then
set userid = 0;
end if;
set userid = Input_uid;
/*查询该用户*/
select * from user where user_id=userid;
/*查询该用户的billing*/
select * from Billing where user_id=userid;
/*查询改用户的会议*/
select * from Conference where author_id=userid;
/*查询改用户Comment*/
select * from Comment where author_id=userid;
/*查询该用户的billing*/
select * from OauthInfo where uid=userid;
/*查询该用户的Feedback*/
select * from Feedback where uid=userid;
/*查询该用户的UserInventory*/
select * from UserInventory where user_id=userid;
/*查询该用户的Deposit*/
select * from Deposit where user_id=userid;
/*查询该用户的Invoice*/
select * from Invoice where user_id=userid;
/*查询该用户的Orders*/
select * from Orders where user_id=userid;
/*查询该用户的Transaction*/
select * from Transaction where user_id=userid;
end;