OLEDB Cursor Questions

Aug 27, 2007

Howdy folks! I have some questions on cursors.

I'm trying to create a RecordSet type object in native oledb which only stores 1 row at a time. The main reason for this is that I very well may be selecting thousands of records and I don't want to run into memory issues storing all those rows. Thus I need to use a cursor to move between records in a Rowset. Unfortunately, I'm required to support SQL query processing, so unless there's an easy workaround, I'm limited to the forward-only and scrollable cursors. Both cursors would work from the functionality standpoint, but I have some concerns with both of them:

Forward-Only:

Although the forward-only read-only cursor is the fastest query processor cursor and the second fastest cursor overall, this cursor provides the least amount of functionality. It does not support bookmarks or updates.


This cursor does not allow quick restarts...in fact, it's mentioned in an msdn article that when this cursor is restarted, it may rerun the query. I would have to restart a forward only cursor to allow for MoveToPrev() and MoveToFirst() functionality. Can anyone confirm that the query is rerun on a restartposition call?

MSDN states that this cursor does not support updates, does this mean that if I execute an UPDATE query on a row within the rowset, then move to that row via GetNextRows the data will be old?

If the above is true, that makes me think the cursor is caching the data. MSDN doesn't state this, but wouldn't that be accurate?
Scrollable:

"The scrollable read-only cursor is the most functional query processor cursor. The result set of this cursor is cached. This provides fast cursor restarts but makes it more resource intensive, especially for queries with large result sets. Because the results are cached, changes to the underlying base tables for a query are not reflected in the query results unless the query is re-executed."


Is the cache the same as just storing all selected rows in memory? If so, why would I bother using this cursor at all instead of storing the rows in my own data structure?
Again if anyone knows a simple way to run SQL queries and still use a base table cursor let me know; otherwise I've got to decide between the slower two.

Thanks in advance!

View 5 Replies


ADVERTISEMENT

Best Method For Setting IRowset Cursor In OLEDB?

Aug 23, 2007

Howdy folks!

I have a need to access random entries in an IRowset object. Looking through the OLEDB documentation there seems to be several options:

1. Just use GetNextRows with positive or negative offset values..
2. Use the IRowsetLocate :: GetRowsAt method
3. Use IRowsetIndex :: Seek to set the cursor
4. Use IRowsetBookmark :: PositionOnBookmark

Which of these are supported and/or recommended for SSCE?

Just to give you an idea of what I'm going for, the application will look something like the following on my own recordset classes:

const BOOL MoveToNext();
const BOOL MoveToPrev();
const BOOL MoveToFirst();
const BOOL MoveToLast();
const BOOL MoveTo(const UINT &cursor);
const UINT GetPosition() const;


Thanks a bunch!
Jeff

View 9 Replies View Related

Cursor And Procedure Questions

May 18, 2008

Hello:I want find that the ntext column data string have more than 2000 characters. I need to truncate those string to the segments with 200 character, then put those segments along with their table_name and column_name to another table. Maybe need to use cursor? If so, how to use it?

Your help is highly appreciated.
S

View 6 Replies View Related

Support For OLEDB Scrollable Updateable Cursor Via Query

Jul 5, 2007

Hi,

is there any update on the subject?

Jet has it for ages.



I want to use Scrollable/Updateable Cursors & OLEDB Rowsets opened via Select query.

Last time I have heard that MSFT is planning to add this in the future.



Is there a beta version that I can try?



Thanks,

Konstantin

View 8 Replies View Related

Error When An OLEDB Source Points To An OLEDB Destination.

Oct 10, 2006

Hi all,

I got an error when i do an OLE db Source pointing to an sql 2000 database and executing a sql query inside the OLE Source. The ole source will point to an OLE DB destination which is an sql 2005 database.

But i got the below error:

Error at Data Flow Task [OLE DB Destination [245]]: the column firstname cannot be processed because more than one code page (936 and 1252) are specified for it.

Error at Data Flow Task [DTS.Pipeline]: "component "OLE DB destination" (245)" failed validation and returned validation status "VS_ISBROKEN".

Error at Data Flow Task [DTS.Pipeline]: One or more component failed validation.

Error at Data Flow TaSK: There were errors during task validation.

(Microsoft.DataTransformationServices.VsIntegration)



View 5 Replies View Related

Transact SQL :: STATIC Defines A Cursor That Makes Temporary Copy Of Data To Be Used By Cursor

Aug 12, 2015

In MSDN file I read about static cursor

STATIC
Defines a cursor that makes a temporary copy of the data to be used by the cursor. All requests to the cursor are answered from this temporary table in
tempdb; therefore, modifications made to base tables are not reflected in the data returned by fetches made to this cursor, and this cursor does not allow modifications

It say's that modifications is not allowed in the static cursor. I have a  questions regarding that

Static Cursor
declare ll cursor global static
            for select  name, salary from ag
  open ll
             fetch from ll
 
              while @@FETCH_STATUS=0
               fetch from ll
                update ag set salary=200 where 1=1
 
   close ll
deallocate ll

In "AG" table, "SALARY" was 100 for all the entries. When I run the Cursor, it showed the salary value as "100" correctly.After the cursor was closed, I run the query select * from AG.But the result had updated to salary 200 as given in the cursor. file says  modifications is not allowed in the static cursor.But I am able to update the data using static cursor.

View 3 Replies View Related

Dynamic Cursor Versus Forward Only Cursor Gives Poor Performance

Jul 20, 2005

Hello,I have a test database with table A containing 10,000 rows and a tableB containing 100,000 rows. Rows in B are "children" of rows in A -each row in A has 10 related rows in B (ie. B has a foreign key to A).Using ODBC I am executing the following loop 10,000 times, expressedbelow in pseudo-code:"select * from A order by a_pk option (fast 1)""fetch from A result set""select * from B where where fk_to_a = 'xxx' order by b_pk option(fast 1)""fetch from B result set" repeated 10 timesIn the above psueod-code 'xxx' is the primary key of the current Arow. NOTE: it is not a mistake that we are repeatedly doing the Aquery and retrieving only the first row.When the queries use fast-forward-only cursors this takes about 2.5minutes. When the queries use dynamic cursors this takes about 1 hour.Does anyone know why the dynamic cursor is killing performance?Because of the SQL Server ODBC driver it is not possible to havenested/multiple fast-forward-only cursors, hence I need to exploreother alternatives.I can only assume that a different query plan is getting constructedfor the dynamic cursor case versus the fast forward only cursor, but Ihave no way of finding out what that query plan is.All help appreciated.Kevin

View 1 Replies View Related

Could Not Complete Cursor Operation Because The Set Options Have Changed Since The Cursor Was Declared.

Sep 20, 2007

I'm trying to implement a sp_MSforeachsp howvever when I call sp_MSforeach_worker
I get the following error can you please explain this problem to me so I can over come the issue.


Msg 16958, Level 16, State 3, Procedure sp_MSforeach_worker, Line 31

Could not complete cursor operation because the set options have changed since the cursor was declared.

Msg 16958, Level 16, State 3, Procedure sp_MSforeach_worker, Line 32

Could not complete cursor operation because the set options have changed since the cursor was declared.

Msg 16917, Level 16, State 1, Procedure sp_MSforeach_worker, Line 153

Cursor is not open.

here is the stored procedure:


Alter PROCEDURE [dbo].[sp_MSforeachsp]

@command1 nvarchar(2000)

, @replacechar nchar(1) = N'?'

, @command2 nvarchar(2000) = null

, @command3 nvarchar(2000) = null

, @whereand nvarchar(2000) = null

, @precommand nvarchar(2000) = null

, @postcommand nvarchar(2000) = null

AS

/* This procedure belongs in the "master" database so it is acessible to all databases */

/* This proc returns one or more rows for each stored procedure */

/* @precommand and @postcommand may be used to force a single result set via a temp table. */

declare @retval int

if (@precommand is not null) EXECUTE(@precommand)

/* Create the select */

EXECUTE(N'declare hCForEachTable cursor global for

SELECT QUOTENAME(SPECIFIC_SCHEMA)+''.''+QUOTENAME(ROUTINE_NAME)

FROM INFORMATION_SCHEMA.ROUTINES

WHERE ROUTINE_TYPE = ''PROCEDURE''

AND OBJECTPROPERTY(OBJECT_ID(QUOTENAME(SPECIFIC_SCHEMA)+''.''+QUOTENAME(ROUTINE_NAME)), ''IsMSShipped'') = 0 '

+ @whereand)

select @retval = @@error

if (@retval = 0)

EXECUTE @retval = [dbo].sp_MSforeach_worker @command1, @replacechar, @command2, @command3, 0

if (@retval = 0 and @postcommand is not null)

EXECUTE(@postcommand)

RETURN @retval



GO


example useage:


EXEC sp_MSforeachsp @command1="PRINT '?' GRANT EXECUTE ON ? TO [superuser]"

GO

View 7 Replies View Related

Join Cursor With Table Outside Of Cursor

Sep 25, 2007

part 1

Declare @SQLCMD varchar(5000)
DECLARE @DBNAME VARCHAR (5000)

DECLARE DBCur CURSOR FOR
SELECT U_OB_DB FROM [@OB_TB04_COMPDATA]

OPEN DBCur
FETCH NEXT FROM DBCur INTO @DBNAME


WHILE @@FETCH_STATUS = 0
BEGIN

SELECT @SQLCMD = 'SELECT T0.CARDCODE, T0.U_OB_TID AS TRANSID, T0.DOCNUM AS INV_NO, ' +
+ 'T0.DOCDATE AS INV_DATE, T0.DOCTOTAL AS INV_AMT, T0.U_OB_DONO AS DONO ' +
+ 'FROM ' + @DBNAME + '.dbo.OINV T0 WHERE T0.U_OB_TID IS NOT NULL'
EXEC(@SQLCMD)
PRINT @SQLCMD
FETCH NEXT FROM DBCur INTO @DBNAME

END

CLOSE DBCur
DEALLOCATE DBCur


Part 2

SELECT
T4.U_OB_PCOMP AS PARENTCOMP, T0.CARDCODE, T0.CARDNAME, ISNULL(T0.U_OB_TID,'') AS TRANSID, T0.DOCNUM AS SONO, T0.DOCDATE AS SODATE,
SUM(T1.QUANTITY) AS SOQTY, T0.DOCTOTAL - T0.TOTALEXPNS AS SO_AMT, T3.DOCNUM AS DONO, T3.DOCDATE AS DO_DATE,
SUM(T2.QUANTITY) AS DOQTY, T3.DOCTOTAL - T3.TOTALEXPNS AS DO_AMT
INTO #MAIN
FROM
ORDR T0
JOIN RDR1 T1 ON T0.DOCENTRY = T1.DOCENTRY
LEFT JOIN DLN1 T2 ON T1.DOCENTRY = T2.BASEENTRY AND T1.LINENUM = T2.BASELINE AND T2.BASETYPE = T0.OBJTYPE
LEFT JOIN ODLN T3 ON T2.DOCENTRY = T3.DOCENTRY
LEFT JOIN OCRD T4 ON T0.CARDCODE = T4.CARDCODE
WHERE ISNULL(T0.U_OB_TID,0) <> 0
GROUP BY T4.U_OB_PCOMP, T0.CARDCODE,T0.CARDNAME, T0.U_OB_TID, T0.DOCNUM, T0.DOCDATE, T3.DOCNUM, T3.DOCDATE, T0.DOCTOTAL, T3.DOCTOTAL, T3.TOTALEXPNS, T0.TOTALEXPNS


my question is,
how to join the part 1 n part 2?
is there posibility?

View 1 Replies View Related

SQL License Questions And Other Questions &&>&&>&&>&&>

Mar 3, 2006

1.    Is it legal  and OK to use a MSDN SQL copy on a production environment or is it strickly for test environments ??

2.   If I own a legal copy of SQL 7 with 5 cals, can I legally use SQL MSDE and have more than 5 people access my SQL server or am I also limited to 5 users as my original ??

 Sorry I am a newbie at this SQL thing.

View 1 Replies View Related

Cursor Inside A Cursor

Oct 5, 2004

I'm new to cursors, and I'm not sure what's wrong with this code, it run for ever and when I stop it I get cursor open errors




declare Q cursor for
select systudentid from satrans


declare @id int

open Q
fetch next from Q into @id
while @@fetch_status = 0
begin

declare c cursor for

Select
b.ssn,
SaTrans.SyStudentID,
satrans.date,
satrans.type,
SaTrans.SyCampusID,
Amount = Case SaTrans.Type
When 'P' Then SaTrans.Amount * -1
When 'C' Then SaTrans.Amount * -1
Else SaTrans.Amount END

From SaTrans , systudent b where satrans.systudentid = b.systudentid

and satrans.systudentid = @id




declare @arbalance money, @type varchar, @ssn varchar, @amount money, @systudentid int, @transdate datetime, @sycampusid int, @before money

set @arbalance = 0
open c
fetch next from c into @ssn, @systudentid, @transdate, @type, @sycampusid, @amount

while @@fetch_status = 0
begin

set @arbalance = @arbalance + @amount
set @before = @arbalance -@amount

insert c2000_utility1..tempbalhistory1
select @systudentid systudentid, @sycampusid sycampusid, @transdate transdate, @amount amount, @type type, @arbalance Arbalance, @before BeforeBalance
where( convert (int,@amount) <= -50
or @amount * -1 > @before * .02)
and @type = 'P'




fetch next from c into @ssn, @systudentid, @transdate, @type, @sycampusid, @amount
end
close c
deallocate c
fetch next from Q into @id

end
close Q
deallocate Q


select * from c2000_utility1..tempbalhistory1
truncate table c2000_utility1..tempbalhistory1

View 1 Replies View Related

Client Side Cursor Vs Sever Side Cursor?

Jul 20, 2005

I having a difficult time here trying to figure out what to do here.I need a way to scroll through a recordset and display the resultswith both forward and backward movement on a web page(PHP usingADO/COM)..I know that if I use a client side cursor all the records get shovedto the client everytime that stored procedure is executed..if thisdatabase grows big wont that be an issue?..I know that I can set up a server side cursor that will only send therecord I need to the front end but..Ive been reading around and a lot of people have been saying never touse a server side cursor because of peformance issues.So i guess im weighing network performance needs with the client sidecursor vs server performance with the server side cursor..I am reallyconfused..which one should I use?-Jim

View 1 Replies View Related

Jet OLEDB

Feb 13, 2008

I'am sure this is an old quesiton but I've spent the whole morning trying to find the answer

What are the string functions suported by Jet in OLEDB queries? In particular, I am desperately looking for a replace function to remove thousands separators from imported text file

View 4 Replies View Related

SqlClient Vs. OleDb

Mar 6, 2005

Hi.

Somewhere around I find a message, which affirmed that for perfonmance it is better to use OleDb for SQL 6.5. Is this true?.

Then el SqlClient, only have perfomance in SQL 2000?

View 1 Replies View Related

OLEDB Provider

Jul 25, 2000

Hi,

Does anyone know a good OLEDB provider for Oracle 7 other than the one of Microsoft and Oracle.

Thank

Martin

View 1 Replies View Related

ODBC Vs OLEDB

Aug 8, 2002

Is anyone using OLEDB instead of ODBC? If so why did you choose to use OLEDB vs ODBC? Our application is written in VB and we have a developer that believes switching to OLEDB from ODBC would be beneficial to us. Please give any information that you have! Thanks.

View 1 Replies View Related

OLEDB Providers

Jul 7, 2004

Hi,

I have a DTS package which is using OLEBD provider for Oracle, it was working fine. I tried to open this package and I got this error message "There was a problem retrieving the list of OLE DB Providers"

I tried to intall MDAC8.2, it didn't help, should I reinstall SQL Server?

Thanks!

View 4 Replies View Related

OLEDB Providers

Nov 19, 2004

can any one please give a technical defenition for OLEDB providers

View 1 Replies View Related

ADO Using ODBC Vs. OLEDB

Jan 13, 2004

I am working on a large ASP application(s) which uses SQL Server 2K on the back end, ADO 2.7 for Data Access. The current connection strings are setup to use older ODBC drivers. I wanted to change them to OLEDB for performance gains and better support in the future.

The problem encountered is that once the driver is changed the pages become riddled with errors. There are many piece of ADO code that are supported using the new driver. Many are cursor issues or code dealing with identity columns.

Has anyone else gone through this process?

Is there a comprehensive listing of those methods that are not compliant between these two drivers?

Any input would be appreciated....Thanks

View 5 Replies View Related

Update && Oledb

Feb 26, 2004

Dear gurus,

My problem: I have developed an application based on sqloledb to access a SQLserver application.

One of the operations is to update certain column of a certain table. This works fine. But with a specific catalog (database) of a specific customer the update hangs for ever on the execution of that sql sentence. Size of the mdb file is around 1 Gb.
The funny thing is that if I execute the same sql sentence (same record and same catalog) from the Query Analyzer ( that I belive it uses odbc ) the operation is done.
The update sql sentence does an update on a non-indexed column with the criteria ( where ...) using a index column (non-clustered)
I have tried the sqlmaint to rebuild indexes and check integrity and no special error report is given.

Also another funny behaviour is that if I stop and I restart sqlserver, the update of that specific record fails, but it continues of the following records to be updated.

This is not executed inside a transaction. Candidate records to be updated are stored in memory (maximum 1000), and one by one are updated.

Does anyone know an specific tool to integrity or to monitor what is going on?
I have tried the profiler , what can I monitor to detect this lock?

Best regards,
Jose

View 1 Replies View Related

SQL ODBC And SQL OLEDB

Feb 6, 2007

I want to know the difference between SQL ODBC and SQL OLEDB.

View 1 Replies View Related

ODBC And OLEDB

Feb 6, 2007

What are ODBC and OLEDB
1)libraries or
2)standards

View 4 Replies View Related

Need Help Regarding OLEDB. RetainSameConnection.

Apr 16, 2008

Hi,

I'm having two For Each Loops, which allow me to dynamically connect to a list of servers.

ForEach 1

ForEach2

DataFlow.



Now for ForEach2 i want to OLEDB Connection to RetainSameConnection, however i want it to Disconnect-Reconnect while looping in ForEach1.

How can i do that?

Can i write a script which will can access OLEDB connection object ??


Thanks
Sandeep.

View 11 Replies View Related

OLEDB Provider For SAS

Jun 6, 2007

Is there an OLEDB provider for SAS? Does anyone know where I could get one? Does it ship with the SAS installation? Thanks!

View 1 Replies View Related

Is It A Bug In SSCE OLEDB ?

May 18, 2007

i'm use this code ,in SQL2005 std and ACCESS database, it work

but if i use SSCE ,it's throw a OleDbException in ExecuteScalar()



Exception : OleDbException





0x80040E30L


DB_E_BADTYPENAME






Code Snippet

OleDbConnection od = new OleDbConnection("Provider=Microsoft.SQLSERVER.MOBILE.OLEDB.3.0;Data Source=db.sdf;SSCE:Database Password=");

od.Open();

OleDbCommand og = new OleDbCommand("INSERT INTO [bills] ([billno],[checkouttime],[finalprice],[handle],[ischeckout],[memo],[paymode],[trick]) VALUES (@billno,@checkouttime,@finalprice,@handle,@ischeckout,@memo,@paymode,@trick)", od);

og.Parameters.Add("@billno", OleDbType.VarWChar).Value = "2007051800000000";
og.Parameters.Add("@checkouttime",OleDbType.DBTimeStamp).Value="2007-5-18 11:55:40";
og.Parameters.Add("@finalprice", OleDbType.Single).Value = 0.0;
og.Parameters.Add("@handle", OleDbType.VarWChar).Value = "admin";
og.Parameters.Add("@ischeckout", OleDbType.SmallInt).Value = 0;
og.Parameters.Add("@memo", OleDbType.VarWChar).Value = "";
og.Parameters.Add("@paymode", OleDbType.VarWChar).Value = "";
og.Parameters.Add("@trick", OleDbType.VarWChar).Value = "";

og.ExecuteScalar();

od.Close();







why the same code is not work? i'm find all MSDN ,but there is no answer



Who can help me,Thanks

View 7 Replies View Related

OLEDB For DM Express!!!

Apr 4, 2007

I am pursuing a course on Data Warehousing & Data Mining as part of my Post-Graduation degree. I got an introduction to Microsoft's OLEDB for DM as part of the course, which got me interested for experiencing it hands-on.

I developed a traditional Database application for my college's library using the .NET 2.0 framework, which is running fine.

Now, I want to see the power of Data Mining in general & OLEDB for DM in particular, to help me mine information & patterns from the mostly transactional data generated by the library daily, like the rush hours, the average issue duration for a book, books that are issued more frequently, books that are issued to students from multiple streams etc. etc.

Now, I have heard MSOLAP provider, ADOMD data provider, SQL Server Analytical Services, OLEDB for DM libraries etc. are required for Data Mining.
Now, what exactly is each of these tools? Are they independent servers for DW & DM like SQL Server for DBs, or they are libraries for extending SQL Server itself?
Moreover, are separate libraries required for OLAP & Mining?

I have SQL Server Express Edition. I believe that they are extensions for SQL Server. So, will they work with Express Edition? If not, are their Express Editions available (like OLEDB for DM Express!!!!) that are compatible with SQL Server Express.

Thanx in advance if you take time to answer so many questions...

View 4 Replies View Related

Version Of OLEDB / ADO

Feb 27, 2006

I want to use SQL 2005 to import data from Visual Foxpro 6.0 free table / database into SQL 2005. Whethter I should install the latest Microsoft OLE DB Provider for Visual FoxPro 9.0 SP1 or previous mdac ???

Please advice and many thanks.

View 1 Replies View Related

OLEDB Access PB

Jul 6, 2007

Hi

I definite a source OLEDB MS Access and my fields of the type €œText€? are seen in type of field DT_WSTR (Unicode) instead of DT_STR.

I do not include/understand why? and like then, I must integrate them in fields varchar and not nVarchar, I do not find the solution?

thank for your solution

View 2 Replies View Related

OLEDB Bookmarks

Sep 4, 2007

I generated an ATL OLEDB Consumer with the VS 2005 wizard. The table is very simple and is located on my local SQL Server. It has two varchar columns and no keys or constraints. I can modify, insert and delete rows with no problem.

Now I want to use bookmarks. I added the following to the accessor class:

1. CBookmark<4> m_bookmark; // member variable
2. pPropSet->AddProperty(DBPROP_IRowsetLocate, true); // rowset property
3. BOOKMARK_ENTRY(m_bookmark) // column map entry

Now I can delete but I can no longer modify or insert. The error is DB_E_ERRORSOCCURED and the status of the two columns after a setdata or insert is DBSTATUS_E_UNAVAILABLE. This is the only error information available.


When I comment out the bookmark entry from the column map, I can modify, insert and delete again. The problem appears to be in how IRowsetChange handles bookmarks. I tried adding bookmarks to other tables using the above 3 steps and they also refuse to modify or insert with bookmarks enabled.

The bookmarks appear to be correct, as I can do a successful MoveToBookmark for any row in the table.

My environment: Windows XP SP2, VC++ 2005, SQL Server 2005 Express, WTL 8.0

Any ideas?

View 3 Replies View Related

How To Verify A DB Via OLEDB?

Jul 30, 2007

I cannot find any OLE DB reference material for how to perform a "Verify" DB as advertised in the Documentation for SQL Server Mobile Edition.

The docs have a sample in C#, but nothing for OLD DB in C++.

Does anyone know how to do this?

View 1 Replies View Related

Oledb For Oracle

Jan 24, 2007

hi,

can i use the acquireconnection method to an oledb for oracle connection manager?

View 1 Replies View Related

Issue Oledb

Mar 26, 2007

I use oledb to insert the data to respective tables..

then i have a look up where i check for unique field of the data i inserted which shows up with an error No matter what i do...

View 12 Replies View Related

SqlClient Vs OLEDb

Feb 29, 2008

I am porting a VB.NET application using Access as its backend to use SQL Express as its new backend.
The application uses .NET 2.0 OleDbProvider to connect to the database.

The porting of the database itself to Sql Express is nearly complete, now I need to modify the application.
So, does it really make sense to modify it to use Native Sql Client instead of OleDb in terms of effort & benefits???

Moreover, if I continue using OleDb, would I need to make such small changes to embedded Sql statements like using single quotes around strings or dates instead of double quotes or pound symbols that are currently being used for String or date data respectively???

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved