[mysql]if exists (select*from sys.objects where type='P' and name='ma_jahr_info')
drop procedure ma_jahr_info
go
create procedure ma_jahr_info
(@jahr int)
AS
BEGIN
if not exists (select*from HumanResources.Employee
where year(hiredate) = @jahr)
raiserror ('Im Jahr %i wurde kein Mitarbeiter eingestellt', 10, 1, @jahr)
else
declare @vorname varchar(50), @famname varchar(50), @job varchar(50)
declare jahr_cur cursor
scroll
for
select firstname, lastname, e.Title
from HumanResources.Employee e
join Person.Contact c
on e.ContactID=c.ContactID
where year(hiredate) = @jahr
open jahr_cur
fetch first from jahr_cur
into @vorname, @famname, @job
while @@fetch_status=0
begin
print @vorname+' '+@famname+' wurde als '+@job+' eingestellt.'
fetch next from jahr_cur
into @vorname, @famname, @job
end
close jahr_cur
deallocate jahr_cur
END
execute ma_jahr_info 2003[/mysql]