存储过程Insert:
BEGIN
#Routine body goes here...
insert into dt_category(title) values(`@namess`);
SET `@ReturnValue`= @@IDENTITY;
END
存储过程select (带条件):
BEGIN
SELECT
*
FROM
dt_users
WHERE
`@company` IS NULL
OR length(`@company`) = 0
OR company LIKE concat("%" ,`@company`, "%")
AND (is_lock = 0 OR is_lock = 3)
AND users_type = 2
LIMIT `@begintop`;
END
delete与上面同理
存储过程事务:
BEGIN
DECLARE t_error integer default 0;
DECLARE ids int default 0;
declare continue handler for SQLEXCEPTION set t_error=1;
start transaction;
insert into dt_category(parent_id) values(`@name1`);
insert into dt_category(parent_id) values(`@name2`);
set ids=LAST_INSERT_ID();
delete from dt_category where title=`@name3` ;
if t_error=1 then
rollback;
SET `@ReturnValue`= 0;
ELSE
SET `@ReturnValue`= ids;
commit;
end if;
END
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。