Questions tagged [cursors]

Cursors are used by database programmers to process individual rows returned by database system queries.

In computer science, a database cursor is a control structure that enables traversal over the records in a database. Cursors facilitate subsequent processing in conjunction with the traversal, such as retrieval, addition and removal of database records. The database cursor characteristic of traversal makes cursors akin to the programming language concept of iterator.

Cursors are used by database programmers to process individual rows returned by database system queries. Cursors enable manipulation of whole result sets at once. In this scenario, a cursor enables the rows in a result set to be processed sequentially.

In SQL procedures, a cursor makes it possible to define a result set (a set of data rows) and perform complex logic on a row by row basis. By using the same mechanics, a SQL procedure can also define a result set and return it directly to the caller of the SQL procedure or to a client application.

A cursor can be viewed as a pointer to one row in a set of rows. The cursor can only reference one row at a time, but can move to other rows of the result set as needed.

http://en.wikipedia.org/wiki/Cursor_(databases)

222 questions
29
votes
3 answers

How do cursors work in Python's DB-API?

I have been using python with RDBMS' (MySQL and PostgreSQL), and I have noticed that I really do not understand how to use a cursor. Usually, one have his script connect to the DB via a client DB-API (like psycopg2 or MySQLdb): connection =…
Nicholas Leonard
  • 2,396
  • 3
  • 26
  • 31
24
votes
7 answers

How to join to tables whose names are stored as values in another table?

Ι have some tables ( eg. [Table1], [Table2], [Table3] and so on ) with a [ID] as primary key and a RecTime as DATETIME on each. Αlso Ι have a table [Files] that hold files in a varbinary(max) column, and refers to the other tables having their Names…
armen
  • 1,170
  • 1
  • 19
  • 38
23
votes
7 answers

How do I disable query results when executing a stored procedure from a stored procedure?

Within a stored procedure, another stored procedure is being called within a cursor. For every call, the SQL Management Studio results window is showing a result. The cursor loops over 100 times and at that point the results window gives up with an…
Alex Angas
  • 56,458
  • 39
  • 130
  • 203
10
votes
1 answer

Do database cursors pick up changes to the underlying data?

Quick question about cursors (in particular Oracle cursors). Let's say I have a table called "my_table" which has two columns, an ID and a name. There are millions of rows, but the name column is always the string 'test'. I then run this PL/SQL…
Lawrence
  • 507
  • 1
  • 5
  • 8
9
votes
3 answers

Programmatically change custom mouse cursor in windows?

I am trying to change the windows cursors (the default is Windows Custom Scheme) to my custom cursors (It named Cut the rope): Is there any idea to change all of cursors (Arrow, Busy, Help Select, Link select,...) to my Cut the rope?
Hoang Viet
  • 135
  • 1
  • 2
  • 8
6
votes
5 answers

Flex 3: How can I change the Mouse Cursor when mousing over a Text Input?

In Flex, by default, when you mouse over a Text Input the mouse cursor is changed to the standard I cross bar. How can I change this cursor so the regular mouse pointer cursor is shown rather than the I cross bar? update: Well, it seems this…
DyreSchlock
  • 870
  • 3
  • 13
  • 24
6
votes
2 answers

Union data from cursors into one

I have stored procedure which executes another stored procedure several times. I need union and return data, which I have after executing second procedure. Can I in some way union data from several cursors into one another cursor? It is possible…
ksogor
  • 843
  • 2
  • 7
  • 15
5
votes
4 answers

Avoid Database Cursor in SQL Server

I have a bit of a puzzle (at least for me) which I am hoping is mostly because I am not yet an SQL master of the universe. Basically I have three tables: Table A, Table B, and Table C. Table C has a FK (Foriegn Key) to Table B, which has FK to…
Streklin
  • 841
  • 1
  • 10
  • 19
4
votes
3 answers

SQL Server Cursor Reference (Syntax, etc)

I don't use SQL Server Cursors often but when I do, I always have to look up the syntax and options. So I wanted to ask, what is the best SQL Server Cursor reference on the web?. I'm looking for a reference that explains all of the (major?)…
Frank V
  • 23,732
  • 32
  • 98
  • 142
4
votes
1 answer

Adobe Flex / as3: How to implement custom drag-and-drop cursors

Our product team has requested custom cursors during drag/drop operations. They have provided me with three images to implement: Open-Hand-Grabber.png: displays when a user hovers over an item that they can drag Closed-Hand-Grabber.png: item is…
user87659
  • 43
  • 1
  • 3
4
votes
3 answers

MySQL Column headers into a single column, second column for the values

I currently have a table that shows the data I need in the format of SELECT * FROM XYZ; Date | Brand | Game1| Game2 | Game3 | 2017 | xxxxx | xxxxxx | ---------- | -----------| 2017 | xxxxx | ----------| yyyyyyy | -----------| 2017 | xxxxx |…
davo777
  • 154
  • 1
  • 9
4
votes
5 answers

Using Custom Colored Cursors in a C# Windows Application

I am developing a SDG (Single Display Groupware) application, and for that I need multiple cursors (to the simplest of different colors) for the single window. I came to know that with C# you can just use black and white cursors, which does not…
Himanshu
  • 73
  • 1
  • 1
  • 5
4
votes
1 answer

Inconsistent cursor results when looping over databases

I have several databases named very similar (my-db-1, my-db-2, my-db-3, my-db-4). I want to execute the same stored procedure on each of these databases. I decided to use cursors. However, I am getting some strange issues. First here is my simple…
smoak
  • 13,086
  • 6
  • 30
  • 33
4
votes
4 answers

TSQL Parent > Child > Sub-Child duplication without cursor

I am creating a SQL 2008 R2 stored procedure to duplicate a row and all it's children. It's a 3-tiered setup with a Parent, Child and Sub-Child Given the ID of the parent I need to create a duplicate. I have solved it using a fast_forward cursor. I…
Matthew
  • 9,896
  • 5
  • 43
  • 95
4
votes
5 answers

solving a problem with cursors

I have a question. I am working on cursors. Each time, after fetching the last records and printing its data’s, the cursor prints an addition line. To understand what I mean please consider the following sample example: I want to print the…
anna
  • 39
  • 1
  • 2
1
2 3
14 15