MySQL创建游标declare这么用为什么会出错?

图片说明

Error Code: 1064.
You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE custcursor cursor for SELECT * FROM customers WHERE cust_email IS NULL' at line 1 0.000 sec

em....你在curtcursor前面加个@试试

create procedure sp_test012
as
begin
declare @custcursor cursor
select * from t
where sex is not NULL
end

游标只能在存储过程里面使用吧