0% found this document useful (0 votes)
24 views1 page

CT 15

The document contains examples of PL/SQL functions, procedures and usage of %ROWTYPE to retrieve records from a table. A function is created to return the total number of books in a table. A procedure is created to update the edition of books. A block uses %ROWTYPE to select and output a book name.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

CT 15

The document contains examples of PL/SQL functions, procedures and usage of %ROWTYPE to retrieve records from a table. A function is created to return the total number of books in a table. A procedure is created to update the edition of books. A block uses %ROWTYPE to select and output a book name.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

2.

3.CREATE OR REPLACE FUNCTION totalbook


RETURN number IS
total number(12) := 0;
BEGIN
SELECT count(*) into total
FROM book;
RETURN total;
END;
/
DECLARE
c number(12);
BEGIN
c := totalbook();
dbms_output.put_line('Total No of books: ' || c);
END;

4.
CREATE OR REPLACE PROCEDURE book_latestedition(
in_edition IN book.edition%TYPE
)
IS
BEGIN

UPDATE book
SET edition ='40'
WHERE edition= in_edition;
END;

begin
book_latestedition('10');
end

5.declare
book_rec book%rowtype;
begin
select * into book_rec from book
where b_id='111';
dbms_output.put_line(book_rec.b_name);
end

6.

You might also like