Hi,
I want to know that what is the role of cursor in database and how can i implement it?
Thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Jan 25, 2012, 1:43 AM
A cursor is a set of rows together with a pointer that identifies a current row.
In other word, Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis.
DECLARE @fName varchar(50), @lName varchar(50)
DECLARE cursorName CURSOR -- Declare cursor
LOCAL SCROLL STATIC
FOR
Select firstName, lastName FROM myTable
OPEN cursorName -- open the cursor
FETCH NEXT FROM cursorName
INTO @fName, @lName
PRINT @fName + ' ' + @lName -- print the name
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM cursorName
INTO @fName, @lName
PRINT @fName + ' ' + @lName -- print the name
END
CLOSE cursorName -- close the cursor
DEALLOCATE cursorName -- Deallocate the cursor
hope this help.
Mukesh KumarPosted Jan 24, 2012, 1:02 PM
refer this link http://www.mssqltips.com/sqlservertip/1599/sql-server-cursor-example/
Satyapriya NayakPosted Jan 24, 2012, 12:31 PM
Please refer the below link
http://plsql-tutorial.com/plsql-cursors.htm
Thanks
VulpesPosted Jan 24, 2012, 11:16 AM
http://www.c-sharpcorner.com/UploadFile/sairevoori/cursor-in-sql-server/