problem with using fetch and a join.

Поиск
Список
Период
Сортировка
От Noel
Тема problem with using fetch and a join.
Дата
Msg-id 3E02BE96.3050502@med.monash.edu.au
обсуждение исходный текст
Ответы Re: problem with using fetch and a join.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: Jeffrey Melloy
Дата:
Сообщение: Re: Which DBD/DBI drivers for postgres 7.2.1 ?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: problem with using fetch and a join.