Hey, save the variable by looping backwards - if the code in the loop
allows it, of course...


FOR A = DCOUNT(WORK.THINGY,VM) TO 1 STEP -1
  code
NEXT A

-----Original Message-----
Also for any newbies watching. Do not put DCOUNT as the second value in
a
FOR...NEXT Loop. Assign it once prior to the FOR statement and the loop
will
be faster.

MAX=DCOUNT(WORK.ITEM.REC<17>,VM)
FOR I=1 TO MAX

My 2 cents
Mark Johnson
----- Original Message -----
From: "Jef Lee" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, November 14, 2008 2:39 AM
Subject: [U2] SELECT-READNEXT That's odd


> One of our programmers wrote this snippet:
>
>       FOR YY=1 TO DCOUNT(WORK.ITEM.REC<17>,VM)
>          LISTNUMBER=''
>          SQLCOMMAND=''
>          UNISTATEMENT='SELECT BPM.WORKITEMS WITH
A1="':WORK.ITEM.REC<1>:'"
AND
> WITH A2="':WORK.ITEM.REC<2>:'" AND WITH A17="':WORK.ITEM.REC<17,YY>:'"
AND
> WITH A24#"C" AND WITH A24#"R" AND WITH A24#"F"'
>          *MY.REC<1>=UNISTATEMENT
>          CALL SR.EXECUTESQL(LISTNUMBER,UNISTATEMENT,SQLCOMMAND)
>          READNEXT DEPENDANT.ID ELSE
>             * NO ACTIVE ITEMS LEFT I NEED TO UPDATE THE STATUS OF THE
> DEPENDANT TASK
>             CALL
> SR.READSQL('BPM.WORKITEMS',DEP.TASK.REC,WORK.ITEM.REC<17,YY>,'')
>             DEP.TASK.REC<24>='A'
>             DEP.TASK.REC<8>=DATE()
>             DEP.TASK.REC<9>=TIME()
>             CALL
> SR.WRITESQL('BPM.WORKITEMS',DEP.TASK.REC,WORK.ITEM.REC<17,YY>)
>          END
>       NEXT YY
>
> The FOR loop has 2 values to iterate, so it does 2 loops. The function
> SR.EXECUTESQL()does the SELECT call.
> Loop 1 returns 2 keys found.
> Loop 2 returns 0 keys found.
> What's odd is that the select list is empty on loop iteration 2 and
the
> READNEXT is populated the ID with the second key from the first
iteration.
>
> I looked in the help PDFs and all I found was a reference to a
corrected
error
> relating to memory not being released if the READNEXT did not exhaust
the
> SELECT list.
>
> Any thoughts?
>
> We have since changed our strategy to check the count returned
instead.
But it
> would be nice to know that others have encountered this as well.
>
> Jeffrey Lee
> Senior Analyst/Programmer
>
> IT Vision Australia Pty Ltd (ABN: 34 309 336 904)
> PO Box 881, Canning Bridge WA 6153
> Level 3, Kirin Centre, 15 Ogilvie Road, Applecross, WA, 6153
> P:  (08) 9315 7000    F: (08) 9315 7088
> W: http://www.itvision.com.au
> ___________________________________________________________
>
> NOTICE : This e-mail and any attachments are intended for the
addressee(s)
> only and may
> contain confidential or privileged material. Any unauthorised review,
use,
> alteration,
> disclosure or distribution of this e-mail (including any attachments)
by
an
> unintended recipient
> is prohibited. If you are not the intended recipient please contact
the
sender
> as soon as
> possible by return e-mail and then delete both messages.
> ___________________________________________________________
> -------
> u2-users mailing list
> [email protected]
> To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

-------------------------------------------------------------------------------------------
Please remember to recycle wherever possible. 
Reduce, reuse, recycle, think do you need to print this e-mail?
-------------------------------------------------------------------------------------------
This e-mail and any attachment(s), is confidential and may be legally 
privileged. It is intended solely for the addressee. If you are not the 
addressee, dissemination, copying or use of this e-mail or any of its content 
is prohibited and may be unlawful. If you are not the intended recipient please 
inform the sender immediately and destroy the e-mail, any attachment(s) and any 
copies. All liability for viruses is excluded to the fullest extent permitted 
by law. It is your responsibility to scan or otherwise check this email and any 
attachment(s). Unless otherwise stated (i) views expressed in this message are 
those of the individual sender (ii) no contract may be construed by this 
e-mail. Emails may be monitored and you are taken to consent to this 
monitoring.  

Civica Services Limited, Company No. 02374268; Civica UK Limited, Company No. 
01628868
Both companies are registered in England and Wales and each has its registered 
office at 2 Burston Road, Putney, London, SW15 6AR.
-------------------------------------------------------------------------------------------
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to