0% found this document useful (0 votes)
61 views

Part 13

PL SQL is a procedural language that combines SQL and procedural programming constructs like conditionals and loops. %ROWTYPE is used when an entire table row is returned by a query, while TYPE RECORD handles columns from different tables. Cursors are required to process queries returning multiple rows individually, and cursor FOR loops implicitly declare a %ROWTYPE variable to represent each row, opening and closing the cursor to iterate through the result set.

Uploaded by

Sumit K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Part 13

PL SQL is a procedural language that combines SQL and procedural programming constructs like conditionals and loops. %ROWTYPE is used when an entire table row is returned by a query, while TYPE RECORD handles columns from different tables. Cursors are required to process queries returning multiple rows individually, and cursor FOR loops implicitly declare a %ROWTYPE variable to represent each row, opening and closing the cursor to iterate through the result set.

Uploaded by

Sumit K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1. What is PL SQL ?

PL SQL is a procedural language which has interactive SQL, as well as procedural


programming language constructs like conditional branching and iteration.

2. Differentiate between % ROWTYPE and TYPE RECORD.

% ROWTYPE is used when a query returns an entire row of a table or view.

TYPE RECORD, on the other hand, is used when a query returns column of different tables
or views.

Eg. TYPE r_emp is RECORD (sno smp.smpno%type,sname smp sname %type)

e_rec smp %ROWTYPE

Cursor c1 is select smpno,dept from smp;

e_rec c1 %ROWTYPE

3. Explain uses of cursor.

Cursor is a named private area in SQL from which information can be accessed. They are
required to process each row individually for queries which return multiple rows.

4. Show code of a cursor for loop.

Cursor declares %ROWTYPE as loop index implicitly. It then opens a cursor, gets rows of
values from the active set in fields of the record and shuts when all records are processed.

Eg. FOR smp_rec IN C1 LOOP

totalsal=totalsal+smp_recsal;

ENDLOOP;

You might also like