problem with using fetch and a join.

From: Noel <noel(dot)faux(at)med(dot)monash(dot)edu(dot)au>
To: pgsql-novice(at)postgresql(dot)org
Subject: problem with using fetch and a join.
Date: 2002-12-20 06:54:14
Message-ID: 3E02BE96.3050502@med.monash.edu.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2002-12-20 14:47:53 Re: problem with using fetch and a join.
Previous Message Jeffrey Melloy 2002-12-20 06:32:20 Re: Which DBD/DBI drivers for postgres 7.2.1 ?