Subject | Re: [firebird-support] Re: something very strange going on here |
---|---|
Author | Lucas Franzen |
Post date | 2006-10-14T12:56:39Z |
Martin,
since if you don't have any record returned back you won't increment
your pos variable thus never reaching the exit, see below..
If your select(max) doesn't return antyhing atermy_try won't be null, it
will be nothing (or when this is happening within a loop, it still wil
hold the last value)
asterm_try = NULL;
if (asterm_try is null) then ...
Use colons when a variable is used for selecting into or within a DML
statement, in all other cases don't use the colon prefix
.
if (pos = 0) then
see above.
and once more ...
and again...
if (pos = 20) then
break;
asterm_temp = asterm_try;
Are you sure you reach this point?
Having alook at your inital post you had data with NULL from outside
IBExpert, so it might be you don't have any records found.
Luc.
> everything's fine; outside the debugger the procedure seems to somehowThe infinite loop might be caused in the FOR BEGIN .. SUSPEND .. END
> strangely enter an infinite loop (but of course I don't know where):
since if you don't have any record returned back you won't increment
your pos variable thus never reaching the exit, see below..
>INIT the asterm_try to NULL.
> CREATE PROCEDURE GET_20_DICENTRIES_BY_ASTERM (
> "TERM" varchar(240))
> returns (
> pos integer,
> id bigint)
> as
> declare variable asterm_try varchar(240) character set unicode_fss;
> declare variable asterm_temp varchar(240) character set unicode_fss;
> begin
> pos = 10;
> asterm_temp = :term;
> while (1 = 1) do
> begin
If your select(max) doesn't return antyhing atermy_try won't be null, it
will be nothing (or when this is happening within a loop, it still wil
hold the last value)
asterm_try = NULL;
> select max(asterm) from dicentries where asterm < :asterm_tempshould read
> into :asterm_try;
> if (:asterm_try is null) then
if (asterm_try is null) then ...
Use colons when a variable is used for selecting into or within a DML
statement, in all other cases don't use the colon prefix
.
> break;pos = pos - 1;
> for select id from dicentries where asterm = :asterm_try order
> by id descending into :id do
> begin
> suspend;
> pos = :pos - 1;
> if (:pos = 0) then
if (pos = 0) then
see above.
> break;if (pos = 0) then
> end
> if (:pos = 0) then
and once more ...
> break;asterm_temp = asterm_try;
> asterm_temp = :asterm_try;
and again...
> endpos = pos + 1;
>
> pos = 11;
> for select id from dicentries where asterm = :term order by id
> ascending into :id do
> begin
> suspend;
> pos = :pos + 1;
> if (:pos = 20) thenif (pos = 20) then
> break;asterm_temp = term;
> end
>
> asterm_temp = :term;
> while (1 = 1) doDo you think this is a good idea?
> beginif (asterm_try is null) then
> select min(asterm) from dicentries where asterm > :asterm_temp
> into :asterm_try;
> if (:asterm_try is null) then
> break;pos = pos + 1;
> for select id from dicentries where asterm = :asterm_try order
> by id ascending into :id do
> begin
> suspend;
> pos = :pos + 1;
> if (:pos = 20) then
if (pos = 20) then
> break;if (pos = 20) then
> end
> if (:pos = 20) then
> break;
> asterm_temp = :asterm_try;
break;
asterm_temp = asterm_try;
Are you sure you reach this point?
Having alook at your inital post you had data with NULL from outside
IBExpert, so it might be you don't have any records found.
Luc.