database-cursor

SQL Server better way to iterate through millions of rows

女生的网名这么多〃 提交于 2021-01-27 23:16:49
问题 I am working with SAP Timesheet data, so there are millions of rows. What I am trying to do is select the data from the SAP table and insert it into a table on MS SQL Server. So I want to insert the original record, then if an update to the original record happens, which is in the form of a new SAP record with a refcounter , I want to find the original record in my table and update it, keeping the original counter value. So I have done this successfully with a cursor (I know not the best),

SQL Server better way to iterate through millions of rows

拈花ヽ惹草 提交于 2021-01-27 22:02:52
问题 I am working with SAP Timesheet data, so there are millions of rows. What I am trying to do is select the data from the SAP table and insert it into a table on MS SQL Server. So I want to insert the original record, then if an update to the original record happens, which is in the form of a new SAP record with a refcounter , I want to find the original record in my table and update it, keeping the original counter value. So I have done this successfully with a cursor (I know not the best),

SQLiteDatabases and Cursors

删除回忆录丶 提交于 2020-03-01 04:06:27
问题 I was wondering if someone could give me a brief overview of Android Cursors. A couple of specific questions: 1 - I have a method which returns a cursor after a database query: public static Cursor getVehicles() { SQLiteDatabase db = vehicleData.getReadableDatabase(); Cursor cursor = db.query(TABLE_NAME, GET_VEHICLES_FROM_CLAUSE, null, null, null, null, ORDER_BY); return cursor; } In order to do housekeeping, I tried db.close() just before the return statement. However, this caused the

SQLiteDatabases and Cursors

大兔子大兔子 提交于 2020-03-01 04:05:05
问题 I was wondering if someone could give me a brief overview of Android Cursors. A couple of specific questions: 1 - I have a method which returns a cursor after a database query: public static Cursor getVehicles() { SQLiteDatabase db = vehicleData.getReadableDatabase(); Cursor cursor = db.query(TABLE_NAME, GET_VEHICLES_FROM_CLAUSE, null, null, null, null, ORDER_BY); return cursor; } In order to do housekeeping, I tried db.close() just before the return statement. However, this caused the

What is an alternative to cursors for sql looping?

孤人 提交于 2020-01-02 02:49:07
问题 Using SQL 2005 / 2008 I have to use a forward cursor, but I don't want to suffer poor performance. Is there a faster way I can loop without using cursors? 回答1: You can do a WHILE loop, however you should seek to achieve a more set based operation as anything in SQL that is iterative is subject to performance issues. http://msdn.microsoft.com/en-us/library/ms178642.aspx 回答2: Here is the example using cursor: DECLARE @VisitorID int DECLARE @FirstName varchar(30), @LastName varchar(30) --

Solving Procedure with no parameters

我只是一个虾纸丫 提交于 2019-12-31 06:42:09
问题 Hey guys just here to see if you guys can help me solve this Procedure problem I am running into. Long story short I made a new table called Create Table ClientHistoricalPurchases( ClientID varchar2(6) constraint clientidhistorical references Clients, DistinctProducts number (9), TotalProducts number(9), TotalCost number (9,2), Primary Key (ClientID)); And I want to populate/update this table by running a procedure that reads primarily from the following table: create table OrderDetails(

Cursor in SQL Server taking too much time for 35 million records

好久不见. 提交于 2019-12-24 06:13:39
问题 I have created a cursor in a stored procedure, my select statement result has around 35 million records. I am fetching each value of cursor and executing the stored procedure, in turn the next stored procedure is calling another stored procedure which has a few insert statements. The query is taking more than 2 days to complete its execution, each time a cursor row takes 0.7 second, and there are 35 million rows. The query is as below: -- Created a cursor to read over data DECLARE testCursor

Cursor in SQL Server taking too much time for 35 million records

霸气de小男生 提交于 2019-12-24 06:11:02
问题 I have created a cursor in a stored procedure, my select statement result has around 35 million records. I am fetching each value of cursor and executing the stored procedure, in turn the next stored procedure is calling another stored procedure which has a few insert statements. The query is taking more than 2 days to complete its execution, each time a cursor row takes 0.7 second, and there are 35 million rows. The query is as below: -- Created a cursor to read over data DECLARE testCursor

TSQL alternative for cursor to loop over Update-trigger data

耗尽温柔 提交于 2019-12-13 05:47:15
问题 In the answers on this case it was suggested that I should not use cursor because of performance reasons. What are the best practices to loop over the update data in an update trigger ? UPDATE: The following is the TSQL for the creation of that update trigger. CREATE TRIGGER [dbo].[trAfterUpdateInfoDoc] ON [dbo].[InfoDocs] AFTER UPDATE AS BEGIN DECLARE @infodoctemplateid INT; DECLARE @infodocid INT; DECLARE @requireccount FLOAT(2); DECLARE @filledcount FLOAT(2); DECLARE @pcnt FLOAT(2);

pyodbc return multiple cursors from stored procedure with DB2

穿精又带淫゛_ 提交于 2019-12-11 07:43:41
问题 I have a python program that calls a stored procedure from db2 database. I am using results = cursor.fetchall() to process the results of my stored procedure. However, my stored procedure returns two cursors. results only contains the first one. I need a way to loop through as many cursors as I want. I was hoping fetchmany() would be my answer but it is not. I need to be able to do multiple result sets as the program I am writing can only call one stored procedure. It would take a lot to go