Advertisement
TheLinkerZero

PL/pgSQL Case Statement

Jul 24th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.73 KB | None | 0 0
  1. DO $$
  2. DECLARE
  3.     test_score INTEGER = random()*10;
  4. BEGIN
  5.     CASE
  6.     WHEN test_score BETWEEN 0 AND 4
  7.         THEN RAISE notice 'your test score is % and that is realy bad, you must have more learning if you want to pass the exam', test_score;
  8.     WHEN test_score BETWEEN 5 AND 7
  9.         THEN RAISE notice 'your test score is % and what job will you get with that score,(if I were you I will go
  10. self-taught and learn other things that you cannot learn just from school ;), if you don''t wana be a civil servant, )', test_score;
  11.     WHEN test_score BETWEEN 8 AND 10
  12.         THEN RAISE notice 'your test score is % and that is a good job, bot don''t be proud of that or you will getting your self on behind', test_score;
  13.     ELSE
  14.         RAISE notice 'Error';
  15.     END CASE;
  16. END $$;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement