Shailrshah

Details about the Movies Costing the Least Using Cursors

Oct 27th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.68 KB | None | 0 0
  1. DECLARE
  2.         CURSOR myCursor IS SELECT * FROM movie;
  3.         minimum         movie.price%TYPE;
  4.         mPoint          myCursor%ROWTYPE;
  5. BEGIN
  6.         OPEN myCursor;
  7.         SELECT MIN(price) INTO minimum FROM movie;
  8.         DBMS_OUTPUT.PUT_LINE('The cheapest ticket costs Rs.' || minimum);
  9.         DBMS_OUTPUT.PUT_LINE('The following movies cost Rs.' || minimum || ':-');
  10.         FETCH myCursor INTO mPoint;
  11.         WHILE myCursor%FOUND LOOP
  12.                 IF (mPoint.price = minimum) THEN
  13.                         DBMS_OUTPUT.PUT_LINE(mPoint.title||' staring ' || mPoint.star || '.');
  14.                 END IF;
  15.                 FETCH myCursor INTO mPoint;
  16.         END LOOP;
  17. END;
  18. /
Add Comment
Please, Sign In to add comment