Hi there,

is there any convenient way to find the predecessor of a record given
a particular order of the database? 

The following select seems a little bit too expensive.

        create table tuples ( i int, j int, m int, k int );

        select * from tuples
        where i<i0
          or ( i=i0 and ( j<j0
            or ( j=j0 and ( k<k0 
              or ( k=k0 and m<m0 )
            ))
          ))
        order by
          i desc, j desc, k desc, m desc
        limit 1;

I would like to have something like:

        declare c cursor for
                select * from tuples
                order by i,j,k,m;
        fetch select *
                where i=i0 and j=j0 and k=k0 and m=m0 
        in c;
        fetch backward 1 in c;

Regards,
        Holger Klawitter
--
Holger Klawitter                                     +49 (0)251 484 0637
[EMAIL PROTECTED]                             http://www.klawitter.de/



************

Reply via email to