Records and Tables
PL/SQL records are similar to C structures.DECLARE
TYPE tEmp IS RECORD (
ENO NUMBER, FNAME VARCHAR2(50), LNAME VARCHAR2(50));
vEmp tEmp;
BEGIN
SELECT id, fname, lname INTO vEmp FROM employee;
END;
You can use %ROWTYPE to specify a variable of table row type. For example,
vEmp employee%ROWTYPE;
PL/SQL Tables are similar to 1-dimensional array in C. You can visualize it as a table with only 2 columns – KEY and VALUE.
DECLARE
TYPE tEmp IS TABLE OF VARCHAR2(50) INDEX BY BINARY_INTEGER;
vEmp tEmp;
BEGIN
vEmp(1) = 'Saikat';
END;
Some table attributes are – tablename.COUNT, DELETE, DELETE(i), FIRST, LAST, NEXT(i), PRIOR(i).
No comments:
Post a Comment