473,508 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MOVE doesn't return number of rows

Dear Postgresql experts,

According to the documentation for MOVE, it returns the number of rows
that it has moved over. It seems to me that this is true for MOVE
FORWARD n, but not for MOVE RELATIVE n or MOVE ABSOLUTE n when it always
returns 1:

db=> declare c scroll cursor for select * from p;
DECLARE CURSOR
db=> move absolute -1 in c;
MOVE 1
db=> move absolute 1 in c;
MOVE 1
db=> move absolute 10 in c;
MOVE 1
db=> move relative 10 in c;
MOVE 1
db=> move relative 100 in c;
MOVE 1
db=> move forward 100 in c;
MOVE 100

Is this a bug?

What I'm actually trying to do is to find the number of rows in the
query result. I was hoping to be able to do a "MOVE ABSOLUTE -1" to get
this. Any other suggestions?

Taking a step further back, here's the real problem: I want to present
the user with an index page to chunks of a table, e.g.

Aardvark - Frog
Frozen - Rabbit
Rabies - Zoo

So I need to get something like rows 1, n/3-1, n/3, 2n/3-1, 2n/3, n.
Efficiency is of concern. Is there some way of asking "WHERE row_number
MOD x < 2"? Currently I am running a count(*) version of the query to
get the number of rows and then running it again with a cursor and
fetching the necessary rows. Any other ideas?

This is with 7.4.2.

Regards,

--Phil.
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #1
1 1980
Phil Endecott <sp**************************@chezphil.org> writes:
According to the documentation for MOVE, it returns the number of rows
that it has moved over.
That's a documentation bug. CVS tip has the correct explanation:

The count is the number of rows that a FETCH command with the same
parameters would have returned (possibly zero).
What I'm actually trying to do is to find the number of rows in the
query result. I was hoping to be able to do a "MOVE ABSOLUTE -1" to get
this. Any other suggestions?


MOVE FORWARD ALL.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
15224
by: Hung Huynh | last post by:
Hi, I'm trying to use either one of these methods to position the cursor in a specific position inside a recordset, but neither one seems to work. For example, I have 10 records in my rsData...
6
1715
by: Alan Silver | last post by:
Hello, I have an ASP that takes a connection string and SQL statement in the querystring and is supposed to return the XML representation of the recordset to the Response stream (don't worry,...
8
6616
by: Jonathan LaRosa | last post by:
Hi all, I have a list box that is populated with enough records such that there are scroll bars and a user will have to scroll through the box to see all of the records. I want to add...
3
2284
by: J | last post by:
I've moved the database tables from the .mdb file to Sql Svr and now I have an *intermittent* problem. When I select a record from a combo box, it will intermittently pull up the wrong record. ...
7
3069
by: tshad | last post by:
Is there a way to move a row in a Datalist up or down without having to re-read the data? I have a datalist which has embedded Datagrids in it. I want to allow the user to move a row up or down...
10
3061
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
17
4565
by: pbd22 | last post by:
Hi. How does one return a range of rows. I know that "Top 5" will return rows 0 - 5 but, how do I get 6 - 10? thanks
3
14383
by: dianaj86 | last post by:
I have multiple dropdownlists each one filled with values from a specific column in the table. Also I have multiple textboxes corresponding to dropdownlists. For example, when I select an item from...
1
4020
by: mazdotnet | last post by:
Hi guys, I can't figure out why this is not working? I need to display all the rows for a given query for a given page index (ex. row 10..20) and the total number of rows. I got the first part...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.