473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

What is cursor? How many Types of cursor? how to create each one?

Hello Friend,
can u send me about cursor? i find it most difficult.

What is cursor? How many Types of cursor? how to create each one?
what r the benefit of each cursor?
Apr 18 '07 #1
6 13146
Hello Friend,
can u send me about cursor? i find it most difficult.

What is cursor? How many Types of cursor? how to create each one?
what r the benefit of each cursor?
Cursors are special programming constructs that allow data to be manipulated on a row-by-row basis, similar to other structured programming languages. They are declared like a variable, and then move one record at a time using a loop for control. There are three types of cursors, DYNAMIC, STATIC, and KEYSET. There are also three types of locks for cursors, READ ONLY, SCROLL LOCKS, and OPTIMISTIC.
Benefit - Featch more records at time for that purpose you can use Cursor.

Eg:
USE pubs
GO
DECLARE get_price CURSOR FOR
SELECT price FROM titles
OPEN get_price
FETCH NEXT FROM get_price
WHILE @@FETCH_STATUS = 0
FETCH NEXT FROM get_price
CLOSE get_price
DEALLOCATE get_price
Oct 17 '07 #2
Cursors are special programming constructs that allow data to be manipulated on a row-by-row basis, similar to other structured programming languages. They are declared like a variable, and then move one record at a time using a loop for control. There are three types of cursors, DYNAMIC, STATIC, and KEYSET. There are also three types of locks for cursors, READ ONLY, SCROLL LOCKS, and OPTIMISTIC.

Eg:
USE pubs
GO
DECLARE get_price CURSOR FOR
SELECT price FROM titles
OPEN get_price
FETCH NEXT FROM get_price
WHILE @@FETCH_STATUS = 0
FETCH NEXT FROM get_price
CLOSE get_price
DEALLOCATE get_price
Oct 17 '07 #3
iburyak
1,017 Expert 512MB
Cursor doesn't have benefits. Main idea is not to use it.

It is the worst and slowest type of programming you can get and used as a last resort when nothing could be done otherwise.


Good Luck.
Oct 17 '07 #4
iburyak
1,017 Expert 512MB
Cursors are special programming constructs that allow data to be manipulated on a row-by-row basis, similar to other structured programming languages. They are declared like a variable, and then move one record at a time using a loop for control. There are three types of cursors, DYNAMIC, STATIC, and KEYSET. There are also three types of locks for cursors, READ ONLY, SCROLL LOCKS, and OPTIMISTIC.

Eg:
USE pubs
GO
DECLARE get_price CURSOR FOR
SELECT price FROM titles
OPEN get_price
FETCH NEXT FROM get_price
WHILE @@FETCH_STATUS = 0
FETCH NEXT FROM get_price
CLOSE get_price
DEALLOCATE get_price
Don't you think you described above VB cursor types not SQL types.... :)
Oct 17 '07 #5
Hi I have a cursor in a Stored Procedure @OutputCursor..It gives me error while executing tht The variable @outputcursor does not have a cursor allocated to it...plz help
Apr 18 '09 #6
Delerna
1,134 Expert 1GB
SnehaAgrawal
Post the code (but in your own thread, not here in someone elses.)

Absolutely agree with Iburyak. Steer clear of cursors unless there is no other way to achieve your objective.
I have seen/performed identical tasks 1 using cursors and the other using queries.
In every case the cursors taking many many minutes (even hours in some cases)
are achieved in seconds using queries and the end results are identical.

Don't get me wrong, cursors do have their place (very occasionally).
Just try and see if you can do it with a query first, and usually you can.


Cursors work through a recordset one row at a time. Slow, especially as recordsets get bigger.
Queries work on an entire recordset as a batch. Much much faster especially as recordsets get bigger.
Apr 20 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Michel Combe | last post by:
Hi all, I'm writing a program that will read an ASCII file periodically and update several tables in a MySQL database. My question is "Can I use the same cursor for several SQL requests (SELECT...
24
by: Xah Lee | last post by:
in computer languages, often a function definition looks like this: subroutine f (x1, x2, ...) { variables ... do this or that } in advanced languages such as LISP family, it is not uncommon...
3
by: robert | last post by:
Mr. Kyte's article doesn't use cursors, while Mr. Feuerstein's book examples do. my recollection of conventional wisdom is to avoid using cursors. is this difference merely a question of style,...
2
by: Christopher Benson-Manica | last post by:
Why isn't there a value for the cursor property that corresponds to "unavailable" (usually the circle with a hash through it)? -- Christopher Benson-Manica | I *should* know what I'm talking...
0
by: Logan | last post by:
I am drawing the current cursor on a zoomed in view of the desktop which seems to be work for all of the cursor types, except that the IBeam is always being drawn inverted (white) even when it...
3
by: Simon Wigzell | last post by:
I have an image with several links in it in mapped areas. I am using a custom cursor on the page and would like to have a custom cursor appear on mouse over of the mapped links. Something like: ...
8
by: Yusuf INCEKARA | last post by:
I have a stored procedure : CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT AS set @RETCUR = CURSOR FORWARD_ONLY STATIC FOR SELECT ID,STORE_NAME FROM T_INF_STORE ORDER BY...
8
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that...
1
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
Can anyone offer pointers to articles/examples of passing a Ref Cursor ***IN*** to an Oracle stored procedure. I find tons of examples for getting a ref cursor OUT of a stored procedure. I'm using...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.