If statement and single piece value in cursor : Explicit Cursor « Cursor « Oracle PL / SQL






If statement and single piece value in cursor

  


SQL> CREATE TABLE products(
  2    name            VARCHAR2(50),
  3    price      NUMBER(8,2)
  4  );

Table created.

SQL>
SQL>
SQL> declare
  2      cursor get_data is select name, price from products;
  3  begin
  4       for i in get_data
  5       LOOP
  6          if i.price > 50 then
  7               dbms_output.put_line(i.name || ' Price: ' || i.price);
  8          end if;
  9       END LOOP;
 10  end;
 11  /

PL/SQL procedure successfully completed.

SQL>
SQL> drop table products;

Table dropped.

SQL>
SQL>

   
    
  








Related examples in the same category

1.Explicit Cursor Demo
2.Implicit and Explicit Cursors
3.an explicit cursor that selects data
4.An explicit cursor fetch loop.
5.Use cursor to store the row count
6.Column value indexed cursor
7.Combine for loop and if statement to check the value in cursor
8.Cursor performance
9.Delete from table where current of cursor
10.Use explicit cursor to fetch and store value to number variable
11.Write an explicit cursor in a FOR loop and use the data