Showing posts with label fetch. Show all posts
Showing posts with label fetch. Show all posts

Wednesday, March 28, 2012

MDAC 2.8 and cursor FETCH NEXT

it seems that starting with MDAC 2.8 the FETCH NEXT statement for cursors requires an INTO clause. otherwise an unspecified error is returned.
so it's not possible to scroll through the records anymore without storing the values of the fields into local variables?Can you post the error code/description ?|||the following code executes from a connection object without issues using ado 2.6 and 2.7:

DECLARE c8281 CURSOR FOR
SELECT * From Users WHERE ( Users.User_ID = 17 )
OPEN c8281
FETCH NEXT FROM c8281
UPDATE [Users] SET
User_Name = 'Unknown'
WHERE CURRENT OF c8281
CLOSE c8281
DEALLOCATE c8281

however, if I use ADO 2.8 it returns error code 80004005 (unspecified error) and native error = 0. furthermore, it actually executes at the database server.

I made it work without errors by modifying the code in the following way:

DECLARE @.username VARCHAR
DECLARE c8281 CURSOR FOR
SELECT User_Name From Users WHERE ( Users.User_ID = 17 )
OPEN c8281
FETCH NEXT FROM c8281 INTO @.username
UPDATE [Users] SET
User_Name = 'Unknown'
WHERE CURRENT OF c8281
CLOSE c8281
DEALLOCATE c8281

which is closer to ansi92 I guess. but I just really need to scroll through the cursor. no need for local variables.

Monday, March 12, 2012

maximum number of rows to fetch

Anybody knows how to change the default 1000 of "maximum number of rows to
fetch" in EM to sth else?
You get that prompt by Open Table-->Return Top...
Thanks,
Wenlei
Wenlei Fang wrote:
> Anybody knows how to change the default 1000 of "maximum number of
> rows to fetch" in EM to sth else?
> You get that prompt by Open Table-->Return Top...
> Thanks,
> Wenlei
I wouldn't use SQL EM for that anyway. Use QA and add a TOP X to the
query to return only the rows you need. SQL EM leaves pages on the
server until you scroll to see them in the UI. This leaves shared locks
on the server on the unfetched pages.
David Gugick
Imceda Software
www.imceda.com
|||I'm totally agree with your point. But what I want to do is to change it to
a smaller number, say 5, so we won't lock any rows and still can view some
sample data.
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:OmPR5vHFFHA.2756@.TK2MSFTNGP15.phx.gbl...
> Wenlei Fang wrote:
> I wouldn't use SQL EM for that anyway. Use QA and add a TOP X to the query
> to return only the rows you need. SQL EM leaves pages on the server until
> you scroll to see them in the UI. This leaves shared locks on the server
> on the unfetched pages.
> --
> David Gugick
> Imceda Software
> www.imceda.com
|||AFAIK there is no way to do this. No documented method anyway.
I second David G's advice. Avoid EM and use Query Analyzer to sample
and view data.
David Portas
SQL Server MVP
|||Davids,
Thank you for your input. Sometimes it is easier and quicker to view table
structure, sample data and insertion through EM than QA as long as you know
what you are doing. And I'm looking for undoc method such as registry hack
etc.
Regards,
Wenlei
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1108653945.639057.128320@.g14g2000cwa.googlegr oups.com...
> AFAIK there is no way to do this. No documented method anyway.
> I second David G's advice. Avoid EM and use Query Analyzer to sample
> and view data.
> --
> David Portas
> SQL Server MVP
> --
>

maximum number of rows to fetch

Anybody knows how to change the default 1000 of "maximum number of rows to
fetch" in EM to sth else?
You get that prompt by Open Table-->Return Top...
Thanks,
WenleiWenlei Fang wrote:
> Anybody knows how to change the default 1000 of "maximum number of
> rows to fetch" in EM to sth else?
> You get that prompt by Open Table-->Return Top...
> Thanks,
> Wenlei
I wouldn't use SQL EM for that anyway. Use QA and add a TOP X to the
query to return only the rows you need. SQL EM leaves pages on the
server until you scroll to see them in the UI. This leaves shared locks
on the server on the unfetched pages.
David Gugick
Imceda Software
www.imceda.com|||I'm totally agree with your point. But what I want to do is to change it to
a smaller number, say 5, so we won't lock any rows and still can view some
sample data.
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:OmPR5vHFFHA.2756@.TK2MSFTNGP15.phx.gbl...
> Wenlei Fang wrote:
> I wouldn't use SQL EM for that anyway. Use QA and add a TOP X to the query
> to return only the rows you need. SQL EM leaves pages on the server until
> you scroll to see them in the UI. This leaves shared locks on the server
> on the unfetched pages.
> --
> David Gugick
> Imceda Software
> www.imceda.com|||AFAIK there is no way to do this. No documented method anyway.
I second David G's advice. Avoid EM and use Query Analyzer to sample
and view data.
David Portas
SQL Server MVP
--|||Davids,
Thank you for your input. Sometimes it is easier and quicker to view table
structure, sample data and insertion through EM than QA as long as you know
what you are doing. And I'm looking for undoc method such as registry hack
etc.
Regards,
Wenlei
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1108653945.639057.128320@.g14g2000cwa.googlegroups.com...
> AFAIK there is no way to do this. No documented method anyway.
> I second David G's advice. Avoid EM and use Query Analyzer to sample
> and view data.
> --
> David Portas
> SQL Server MVP
> --
>

maximum number of rows to fetch

Anybody knows how to change the default 1000 of "maximum number of rows to
fetch" in EM to sth else?
You get that prompt by Open Table-->Return Top...
Thanks,
WenleiWenlei Fang wrote:
> Anybody knows how to change the default 1000 of "maximum number of
> rows to fetch" in EM to sth else?
> You get that prompt by Open Table-->Return Top...
> Thanks,
> Wenlei
I wouldn't use SQL EM for that anyway. Use QA and add a TOP X to the
query to return only the rows you need. SQL EM leaves pages on the
server until you scroll to see them in the UI. This leaves shared locks
on the server on the unfetched pages.
--
David Gugick
Imceda Software
www.imceda.com|||I'm totally agree with your point. But what I want to do is to change it to
a smaller number, say 5, so we won't lock any rows and still can view some
sample data.
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:OmPR5vHFFHA.2756@.TK2MSFTNGP15.phx.gbl...
> Wenlei Fang wrote:
>> Anybody knows how to change the default 1000 of "maximum number of
>> rows to fetch" in EM to sth else?
>> You get that prompt by Open Table-->Return Top...
>> Thanks,
>> Wenlei
> I wouldn't use SQL EM for that anyway. Use QA and add a TOP X to the query
> to return only the rows you need. SQL EM leaves pages on the server until
> you scroll to see them in the UI. This leaves shared locks on the server
> on the unfetched pages.
> --
> David Gugick
> Imceda Software
> www.imceda.com|||AFAIK there is no way to do this. No documented method anyway.
I second David G's advice. Avoid EM and use Query Analyzer to sample
and view data.
--
David Portas
SQL Server MVP
--|||Davids,
Thank you for your input. Sometimes it is easier and quicker to view table
structure, sample data and insertion through EM than QA as long as you know
what you are doing. And I'm looking for undoc method such as registry hack
etc.
Regards,
Wenlei
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1108653945.639057.128320@.g14g2000cwa.googlegroups.com...
> AFAIK there is no way to do this. No documented method anyway.
> I second David G's advice. Avoid EM and use Query Analyzer to sample
> and view data.
> --
> David Portas
> SQL Server MVP
> --
>