Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. ALTER FUNCTION "DBA"."Wolne_samochody"()
  2. RETURNS INTEGER
  3. DETERMINISTIC
  4. BEGIN
  5. DECLARE return_name integer;
  6. DECLARE kursor dynamic scroll cursor for select "DBA"."Samochody"."id_statusu" from Samochody;
  7. DECLARE @statuss integer;
  8. DECLARE @ilosc integer;
  9. DECLARE i int;
  10. SET i=0;
  11. SET @statuss=0;
  12. SET @ilosc=0;
  13. OPEN kursor;
  14. while i < (SELECT count(*) from Samochody)
  15. LOOP
  16. SET i=i+1;
  17. FETCH NEXT kursor INTO @statuss;
  18. IF (statuss=2)
  19. THEN
  20. BEGIN
  21. SET @ilosc=@ilosc+1;
  22. END
  23. END IF;
  24. END LOOP;
  25. CLOSE kursor;
  26. set return_name = @ilosc;
  27. RETURN "return_name";
  28. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement