BDG Scenario 3

lw_getClassList.sql

ALTER PROC lw_getClassList(
   @groupId int
) AS
set nocount on
select p.* from [group] g
      join personGroup pg on g.groupId=pg.groupId
      join person p on pg.personId=p.personId
   where g.groupId=@groupId
   order by p.lastName

--- TESTING
declare @groupId int
declare classes cursor read_only forward_only
   for select distinct groupId from [group]
open classes
fetch from classes into @groupId
while @@FETCH_STATUS=0
begin
   print 'CLASS LIST FOR: ' + convert(char(10),@groupId)
   exec lw_getClassList @groupId
   fetch next from classes into @groupId
end
close classes
deallocate classes