Subject Re: incorrect results, still :-(
Author martinknappe
Hey just in case there's still someone left who's not put me on ignore
yet *lol
The sp really seems to work now; i did it via a trick (splitting the
task between 2 sp's):

CREATE PROCEDURE NEXT_20_AB_ASTERM_AUX (
asterm_in varchar(240),
id_in bigint)
returns (
id_out bigint,
pos integer)
as
declare variable cnt integer;
declare variable asterm_tmp varchar(240) character set unicode_fss;
declare variable asterm_prior varchar(240) character set unicode_fss;
begin
pos = 0;
cnt = 0;
asterm_prior = asterm_in;
for select asterm, id from dicentries where (asterm = :asterm_in and
id >= :id_in) or (asterm > :asterm_in) order by asterm ascending into
:asterm_tmp, :id_out do
begin
cnt = cnt + 1;
if (asterm_tmp <> asterm_prior) then
begin
pos = pos + 1;
asterm_prior = asterm_tmp;
end
suspend;
if (cnt = 20) then
exit;
end
end




CREATE PROCEDURE NEXT_20_AB_ASTERM (
asterm_in varchar(240),
id_in bigint)
returns (
id_out bigint,
pos integer)
as
begin
pos = 0;
for select id_out from next_20_ab_asterm_aux(:asterm_in, :id_in)
order by pos ascending, id_out ascending into :id_out do
begin
suspend;
pos = pos + 1;
end
end

I see no other way of getting fb 1.5 to do this correctly :-)



--- In firebird-support@yahoogroups.com, "martinknappe" <martin@...>
wrote:
>
> > You are still fiddling with :id_prior and :asterm_prior which are
used
> > in the outer query. Why don't you write it like this:
>
> I just tried it. It doesnt help.
> What's interesting to know:
>
> asterm from dicentries where id = 34 is 'Lackreiniger, m'
>
> select * from next_20_by_asterm('Lackreiniger, m', 34) gives me the
> wrong result
>
> but
>
> select * from next_20_by_asterm('Lackreiniger, m', 0) gives me the
> right result (as there happen to be no other records where asterm =
> 'Lackreiniger, m' beside record with id 34)
>
> You can try for yourself with the sample database (but you need to
> install the fbintl2.dll into your firebird intl directory provided you
> have fb running under windows:
>
> http://www.yourfilehost.com/media.php?cat=other&file=3071Desktop.rar
>
> Thanx again,
>
> martin
>