problem with using fetch and a join. - Mailing list pgsql-novice

From Noel
Subject problem with using fetch and a join.
Date
Msg-id 3E02BE96.3050502@med.monash.edu.au
Whole thread Raw
Responses Re: problem with using fetch and a join.
List pgsql-novice
Hi
I'm performing the following sql statements:

begin;
declare test cursor for
select protein.accession
from protein, region
where protein.accession like '%1245%'
and protein.accession = region.accession
and region.protein_database = 1;
fetch forward 2 in test;

result -->

accession
Q12454/3-180
CA11_HUMAN/1245-1463
total of 2 rows

All good.

However if i perform these:

begin;
declare test cursor for
select protein.accession
from protein, region
where protein.accession like '%1245%'
and protein.accession = region.accession
and region.protein_database = 1;
fetch forward 2 in test;
fetch backward 1 in test;

NO RESULT!!

Then if I change the select statement to this:

begin;
declare test cursor for
select accession
from protein
where accession like '%1245%';
fetch forward 100 in test;

result -->
accession
22991245
1245847
22124507
91245
1245381
11245811
.......
21245076
total of 100 results

And with the fetch backward statement added:

begin;
declare test cursor for
select accession from protein
where accession like '%1245%';
fetch forward 3 in test;
fetch backward 2 in test;

Result -->

accession
1245847
22991245

As expected.

The only difference between the two select statements is that the first
statement involves two tables to collect the results.
Can someone explain why the fetch backward statement returns no result
in the first statement but dose in the second.


Many thanks
--
Noel Faux
Department of Biochemistry and Molecluar Biology
Monash University
Clayton 3168
Victoria
Australia


pgsql-novice by date:

Previous
From: Jeffrey Melloy
Date:
Subject: Re: Which DBD/DBI drivers for postgres 7.2.1 ?
Next
From: Tom Lane
Date:
Subject: Re: problem with using fetch and a join.