Questions tagged [cursor]

A cursor is a control structure for traversing records in a database.

Filter by
Sorted by
Tagged with
2 votes
0 answers

Cursor-based search result pagination

Can you guys review my GraphQL search pagination function? I'm afraid there could be some performance issues, or something. Especially at the aggregation section and this ...
SnekNOTSnake's user avatar
3 votes
2 answers

Reading complete contact information in Android

My goal is to read complete contact information on an Android application. This is very slow and my understanding is that since the contacts are stored locally in a phone database, it shouldn't take ...
AppsWise's user avatar
  • 133
8 votes
3 answers

MySQL-to-PostgreSQL migration script

I'm working on a Python script to migrate a MySQL database into a PostgreSQL database with a different Schema (different table structures, different datatypes and so on). I'm a sysadmin and ...
lese's user avatar
  • 145
3 votes
1 answer

Is the usage of SQL Cursor appropriate here?

I'm looking for following kind of feedback: Firstly, is the use of a cursor an overkill here? Is there a simpler way to do what I'm doing in SQL? Could the script go terribly wrong? I have limited ...
Force444's user avatar
  • 243
3 votes
2 answers

SQL cursors and dynamic SQL

The idea is to have a heading for each date returned by the query. This could be any number of dates. I dynamically altered the #table which is ugly but there is no other way. Ultimately I would ...
user30586's user avatar
  • 237
7 votes
3 answers

SQL Stored Procedure Get Distinct and Update

The idea is to show how many times a user (by EmployeeID) is in the TblTableList and then update the ...
indofraiser's user avatar
8 votes
3 answers

Return the top 5 of each kind of record

I have this currently working code, but it's extremely slow. I'm talking almost an hour to execute, if it executes at all (our server isn't all that great to start with). Is there a better way to ...
Volearix's user avatar
  • 829
22 votes
1 answer

Calculating Lost Reputation

A discussion arose not long ago on the 2nd Monitor about how much reputation has been lost due to the reputation caps. There are a number of queries on the SEDE which try to address this: A Users ...
rolfl's user avatar
  • 97.3k
3 votes
1 answer

Simple decorator for creating and managing a database cursor

I'm working on a simple decorator that creates and manages a database cursor. The goal is to 'inject' the cursor as the first argument of the function, but not expose it to the caller. Usage: ...
DiogoNeves's user avatar
3 votes
1 answer

DRY cursors: preventing T-SQL's FETCH statement from being repeated

Please assume I've exhaustively tried to come up with a set-based solution to my T-SQL problem, and that I need to use a cursor. The following is the typical1 boilerplate for a T-SQL cursor: ...
Jeroen's user avatar
  • 1,441