Those who never forget and are perfect typists have a hard time understand 
those that are challenged in these areas!

Dennis McGrath
Software Developer
QMI Security Solutions
1661 Glenlake Ave
Itasca IL 60143
630-980-8461
[email protected]
From: [email protected] [mailto:[email protected]] On Behalf Of Karen Tellef
Sent: Friday, March 21, 2014 9:15 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: Thanks to someone for the code!

That's the way I standardize all my cursor loops too.  Exactly as you have it 
written (well, I don't have parenthesis around the "1").  I love having only 
one "fetch" statement.  Back in the days when I did 2 fetch statements, how 
many times did I change one of the fetches and forget to change the other?  
Umm, a few....

Karen



-----Original Message-----
From: Dennis McGrath <[email protected]<mailto:[email protected]>>
To: RBASE-L Mailing List <[email protected]<mailto:[email protected]>>
Sent: Fri, Mar 21, 2014 9:08 am
Subject: [RBASE-L] - Re: Thanks to someone for the code!

That is true if you use WHILE SQLCODE <> 100



In this case, if I WAS using a WHILE loop I would WRITE it this way, which will

never exit unless the fetch throws 100:



DROP CURSOR c1

DECLARE c1 CURSOR FOR SELECT  ....... blah blah blah

OPEN c1

WHILE (1) = (1) THEN

  FETCH c1 INTO ..... blah blah blah

  IF SQLCODE = 100 THEN

    BREAK

  ENDIF

  -- do all your processing here

ENDWHILE

WRITE 'I AM DONE!'





Dennis McGrath

Software Developer

QMI Security Solutions

1661 Glenlake Ave

Itasca IL 60143

630-980-8461

[email protected]<mailto:[email protected]>

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]<mailto:[email protected]?>] On Behalf Of

[email protected]<mailto:[email protected]>

Sent: Friday, March 21, 2014 8:50 AM

To: RBASE-L Mailing List

Subject: [RBASE-L] - Re: Thanks to someone for the code!



I believe that if within the while loop exits a command that sets SQLCODE = 100

(—do all your processing here) while loop does not work.

Daniele



From: Tony IJntema

Sent: Friday, March 21, 2014 12:40 PM

To: RBASE-L Mailing List

Subject: [RBASE-L] - Re: Thanks to someone for the code!



Karen,



Maybe not relevant, but why don’t you use the while-endwhile construction.

If statements are handy, but also a little dangerous

10 if statements in a program will result in 1024 paths through your program



Tony



DROP CURSOR c1

DECLARE c1 CURSOR FOR SELECT  ....... blah blah blah

OPEN c1

FETCH c1 INTO ...... blah blah blah

while SQLCODE <>  100 THEN

       -- do all your processing here



FETCH c1 INTO ..... blah blah blah

endwhile

WRITE 'I AM DONE!'



From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]<mailto:[email protected]?>] On Behalf Of Karen Tellef

Sent: donderdag 20 maart 2014 23:18

To: RBASE-L Mailing List

Subject: [RBASE-L] - Re: Thanks to someone for the code!



Well then, I'm guessing it was either Dennis or Alastair!  Or both!



Karen







-----Original Message-----

From: Alastair Burr <[email protected]<mailto:[email protected]>>

To: RBASE-L Mailing List <[email protected]<mailto:[email protected]>>

Sent: Thu, Mar 20, 2014 2:21 pm

Subject: [RBASE-L] - RE: Thanks to someone for the code!

And I, for one, have been using it for many of those years.



Cheers, Dennis,

Regards,

Alastair.



From: Dennis McGrath

Sent: Thursday, March 20, 2014 7:01 PM

To: RBASE-L Mailing List

Subject: [RBASE-L] - RE: Thanks to someone for the code!



Perhaps someone else shared that with you but I’m been preaching that style for

mucho many years.



Dennis McGrath

Software Developer

QMI Security Solutions

1661 Glenlake Ave

Itasca IL 60143

630-980-8461

[email protected]<mailto:[email protected]>

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]<mailto:[email protected]?>?] On Behalf Of Karen Tellef

Sent: Thursday, March 20, 2014 1:52 PM

To: RBASE-L Mailing List

Subject: [RBASE-L] - Thanks to someone for the code!



Probably a year ago I asked for recommendations of how to use alternative code

for a cursor that had to go through 50,000 rows of data, run hundreds of lines

of code per record, and would periodically lock up.  I got a couple examples,

and I picked this one as being the easiest to follow, the simplest and best of

all, IT WORKS!   I forgot who gave it to me, but thank you!   And perhaps this

will help someone else.



Karen



DROP CURSOR c1

DECLARE c1 CURSOR FOR SELECT  ....... blah blah blah

OPEN c1



LABEL GetCursor



FETCH c1 INTO ..... blah blah blah



IF SQLCODE = 100 THEN

  GOTO EndCursor

ENDIF



-- do all your processing here



GOTO GetCursor





LABEL EndCursor

WRITE 'I AM DONE!'





RETURN



________________________________________



Questa e-mail è priva di virus e malware perché è attiva la protezione avast!

Antivirus .


Reply via email to