PL/SQL What is the difference between rowtype and type
What is the difference between rowtype and type
%TYPE is used to get type of a variable or a table column.
v_name customers.name%TYPE;
%ROWTYPE is used to obtain the type of line of a cursor or table.
DECLARE
CURSOR c is SELECT id, name, type, email
FROM customers
WHERE type = 'CORPORATE';
cust_rec c%ROWTYPE;
BEGIN
OPEN c;
LOOP
FETCH c INTO cust_rec;
EXIT WHEN c%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('Customer name: '||cust_rec.name||' '||cust_rec.email);
END LOOP;
CLOSE c;
END;