Mohammed Alaslani Blog

April 10, 2010

Cursors in PL/SQL

Filed under: Uncategorized — maslani4 @ 3:00 pm

A Cursors is Pointer to memory location on database server , and DBMS uses to process a SQL query.

An example of cursor

DECLARE

CURSOR student_cur IS

SELECT student_name, student_id FROM student;

– declare record variable that represents a row fetched from the studentt table

student_rec student_cur%ROWTYPE;

BEGIN

– open the explicit cursor and use it to fetch data into student_rec

OPEN student_cur;

LOOP

FETCH student_cur INTO student_rec;

EXIT WHEN student_cur%NOTFOUND;

DBMS_OUTPUT.PUT_LINE(student_rec.student_name || ‘ , ‘ ||   student_rec.student_id);

END LOOP;

END;

Written by: Mohammed Alaslani

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.