what is cursor. write example of it. What are the attributes of cursor.



what is cursor. write example of it. What are the attributes of cursor...

Answer / Kavindra Singh Thakur

A cursor is a database object that represents a dynamic set of rows returned from a SELECT statement during its execution. You can iterate through each row of a result set using a cursor.

Example:

```sql
DECLARE
my_cursor SYS_REFCURSOR;
emp employees%ROWTYPE;
BEGIN
OPEN my_cursor FOR
SELECT * FROM employees WHERE department_id = 10;
LOOP
FETCH my_cursor INTO emp;
EXIT WHEN my_cursor%NOTFOUND;
-- Process the current row here...
END LOOP;
CLOSE my_cursor;
END;"

The attributes of a cursor are:
- %ISOPEN: Returns true if the cursor is open.
- %ROWS: Returns the number of rows currently in the cursor.
- %NOTFOUND: Returns true when there are no more rows to fetch from the cursor.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What is an ndf file?

1 Answers  


Write the order of precedence for validation of a column in a table ?

2 Answers  


what is the difference between union and union all

14 Answers   IBM, Luxoft, Oracle,


what is difference between stored procedures and application procedures,stored function and application function?

1 Answers  


Hello All, Could any well write a query for the following scenario. Account(table name) No Name Amount 1 ABCD 2000.00 2 DEFG -2000.00 3 GHIJ 3000.50 4 JKLM 4000.00 5 MNOP 6000.00 O/p Should be in this format No Name Credit Debit 1 ABCD 2000.00 0 2 DEFG 0 -2000.00 3 GHIJ 3000.50 4 JKLM 0 -4000.00 5 MNOP 6000.00 o could any one give appropriate query for this Thnks in Advance Suneel Reddy

6 Answers   Target,


Why we use joins in sql?

1 Answers  


how many tupples can insert in 1 second in sql

1 Answers  


can use the following like overloading concept in a single package: procedure p1(a varchar), procedure p1(a varchar2), procedure p1(a char)

5 Answers  


1. Which is an aggregate function? a. Union b. like c. max d. Rank

1 Answers   Fintellix,


What are sql ddl commands?

1 Answers  


How many null values can be inserted in a coulmn whihc is unique constraint

8 Answers   Flextronics,


What are all the ddl commands?

1 Answers  


Categories