Record Based Insert Example:
DECLARE
my_book books%ROWTYPE;
BEGIN
my_book.isbn := '1-123456-123-1';
my_book.title := 'Fox Infotech Blogs';
my_book.summary := 'Fox Examples';
my_book.author := 'V. Kapoor';
my_book.page_count := 300;
INSERT INTO books VALUES my_book;
END;
/
Notice that you do not include parentheses around the record specifier. If you use this format:
INSERT INTO books VALUES (my_book); -- With parentheses, INVALID!
then you will get an ORA-00947: not enough values exception, since the program is expecting a separate expression for each column in the table.
Record Based Update Example:
DECLARE
my_book books%ROWTYPE;
BEGIN
my_book.isbn := '1-123456-123-1';
my_book.title := 'Fox Infotech Blogs';
my_book.summary := 'Fox Examples';
my_book.author := 'V. Kapoor';
my_book.page_count := 300;
UPDATE books
SET ROW = my_book
WHERE isbn = my_book.isbn;
END;
/
There are some restrictions on record-based updates: