Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ALTER FUNCTION [dbo].zad5(@tytul varchar(30))
- RETURNS varchar(max)
- AS
- BEGIN
- DECLARE
- @ile int,
- @result varchar(max)
- SET @ile = (select count(*) from [wypozyczenie]
- join ksiazka on ksiazka.IdKsiazka = wypozyczenie.idKsiazka
- where tytul = @tytul)
- SET @result = 'Ksiażka ' + convert(varchar(15),@tytul) + ' była wypożyczana ' + convert(varchar(2),@ile)
- RETURN @result
- END
- /* wywołanie */
- DECLARE kursor CURSOR FOR
- select tytul from ksiazka
- declare @tytul varchar(30)
- open kursor
- fetch next from kursor into @tytul
- while @@FETCH_STATUS = 0
- begin
- print dbo.zad5(@tytul)
- fetch next from kursor into @tytul
- end
- close kursor
- deallocate kursor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement