drop PROCEDURE if exists my_procedure; create PROCEDURE my_procedure() BEGIN declare my_sqll varchar(500); set my_sqll='select * from aa_list'; set @ms=my_sqll; PREPARE s1 from @ms; EXECUTE s1; deallocate prepare s1; end;
call sp_add();
是不是你定義的過程有問題吧,並沒有指出返回結果來
像我這樣是可以的:
CREATE PROCEDURE sp_add(a int, b int,out c int)
begin
set c=a+ b;
end;
調用過程:
call sp_add (1,2,@a);
select @a;
declare @d1 datetime
set @d1 = '2009-12-31'
select dateadd(year,-1,@d1) as 上一年同一天的日期