Hello,
this is driving me crazy :(

I have a screen that lets the user add/remove multiple items to an assembly.
The items are stored in an array whilst they edit and then stored in the
main table if they save.

The save routine looks like this:

SELECT pri_det
m.arrayref=1
m.arraylen=ALEN(priceinf,1)
SCAN FOR wk_ref = m.ref
IF m.arrayref<=m.arraylen
* already existing record - replace contents
REPLACE pri_det.saparticle WITH RIGHT(priceinf[m.arrayref],6)
m.arrayref=m.arrayref+1
ELSE
* array has fewer records than table - delete record
DELETE
ENDIF
ENDSCAN
* add any remaining records from array to table
DO WHILE m.arraylen>=m.arrayref
INSERT INTO pri_det VALUES (m.ref,RIGHT(priceinf[m.arrayref],6))
m.arrayref=m.arrayref+1
ENDDO

Sometimes when they remove items, this doesn't work correctly and the
SCAN..ENDSCAN doesn't loop all the records in its FOR clause. Does anyone
know WHY!?!!

1) There is no filter set.
2) I've recreated the indexes with INDEX ON. (although I haven't tried a
SCAN.. NOOPTIMIZE yet)
3) I've pulled that routine out into a separate program (working on the same
table) to try to reproduce and it seems to work fine.
4) I wrote a little program that SCANS the same clause just doing an
incremental count to a vraible and then display the result in a wait window.
I used my screen to remove some items and broke the save routine just before
the SCAN. At this point I ran my counting program - it showed a SCAN FOR
wk_ref=m.ref count of 5 records. When then went on to single step the save
routine it only SCANned 3.

What on earth could possibly be wrong here?

--
TIA
Andrew Howell

Re: FPW2.6a SCAN FOR missing records by Gregory

Gregory
Wed Aug 04 05:05:09 CDT 2004

hi Andrew,

Is there an active index ? If yes, would you be replacing items that are
part of the active index ?

Try with no active index, ie

set order to
scan all for wk_ref = m.ref

.....

endscan

hth,

Gregory
___________________________________
"Andrew Howell" <ajh@work> wrote in message
news:ewDUQVgeEHA.3632@TK2MSFTNGP11.phx.gbl...
> Hello,
> this is driving me crazy :(
>
> I have a screen that lets the user add/remove multiple items to an
assembly.
> The items are stored in an array whilst they edit and then stored in the
> main table if they save.
>
> The save routine looks like this:
>
> SELECT pri_det
> m.arrayref=1
> m.arraylen=ALEN(priceinf,1)
> SCAN FOR wk_ref = m.ref
> IF m.arrayref<=m.arraylen
> * already existing record - replace contents
> REPLACE pri_det.saparticle WITH RIGHT(priceinf[m.arrayref],6)
> m.arrayref=m.arrayref+1
> ELSE
> * array has fewer records than table - delete record
> DELETE
> ENDIF
> ENDSCAN
> * add any remaining records from array to table
> DO WHILE m.arraylen>=m.arrayref
> INSERT INTO pri_det VALUES (m.ref,RIGHT(priceinf[m.arrayref],6))
> m.arrayref=m.arrayref+1
> ENDDO
>
> Sometimes when they remove items, this doesn't work correctly and the
> SCAN..ENDSCAN doesn't loop all the records in its FOR clause. Does anyone
> know WHY!?!!
>
> 1) There is no filter set.
> 2) I've recreated the indexes with INDEX ON. (although I haven't tried a
> SCAN.. NOOPTIMIZE yet)
> 3) I've pulled that routine out into a separate program (working on the
same
> table) to try to reproduce and it seems to work fine.
> 4) I wrote a little program that SCANS the same clause just doing an
> incremental count to a vraible and then display the result in a wait
window.
> I used my screen to remove some items and broke the save routine just
before
> the SCAN. At this point I ran my counting program - it showed a SCAN FOR
> wk_ref=m.ref count of 5 records. When then went on to single step the save
> routine it only SCANned 3.
>
> What on earth could possibly be wrong here?
>
> --
> TIA
> Andrew Howell
>
>


Re: FPW2.6a SCAN FOR missing records by Andrew

Andrew
Wed Aug 04 06:41:23 CDT 2004

Gregory Adam wrote:
> hi Andrew,
>
> Is there an active index ? If yes, would you be replacing items that
> are part of the active index ?

Yes, and yes. We need a blush emoticon; I'd place one here.. It seems so
obvious now but that's always the way with hindsight.

>
> Try with no active index, ie

and it works.
Once again I'm indebted to your superior problem solving skills, thank you
*so much* Gregory.

--
Regards
Andrew Howell



Re: FPW2.6a SCAN FOR missing records by Gregory

Gregory
Wed Aug 04 06:52:44 CDT 2004

You're welcome Andrew.

It's happened to me too. That's why people remember

You may have to change your logic a bit now, since you do not know the
sequence of the items scanned
(you could select a subset into a cursor using order by, scan the cursor and
update pri_det)

Gregory
____________
"Andrew Howell" <ajh@work> wrote in message
news:u6iy6fheEHA.644@tk2msftngp13.phx.gbl...
> Gregory Adam wrote:
> > hi Andrew,
> >
> > Is there an active index ? If yes, would you be replacing items that
> > are part of the active index ?
>
> Yes, and yes. We need a blush emoticon; I'd place one here.. It seems so
> obvious now but that's always the way with hindsight.
>
> >
> > Try with no active index, ie
>
> and it works.
> Once again I'm indebted to your superior problem solving skills, thank you
> *so much* Gregory.
>
> --
> Regards
> Andrew Howell
>
>