Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Using EXISTS function as a condition in a WHILE loop
Tue, May 18 2010 12:34 AMPermanent Link

Richard Harding

Wise Nutrition Coaching

Is it possible to construct WHILE loop that uses an EXISTS function as the condition?  Something like  - - -

  WHILE EXISTS (SELECT * FROM table1 WHERE X = 0) DO    
    <stuff>
  END WHILE;

At present I am doing the following:

 OPEN tmpCursor;
 SET I = ROWCOUNT(tmpCursor);
 CLOSE tmpCursor;

 WHILE I > 0 DO
   <stuff>

   OPEN tmpCursor;
   SET I = ROWCOUNT(tmpCursor);
   CLOSE tmpCursor;
 END WHILE;

which is not very elegant.

Richard Harding
Tue, May 18 2010 4:02 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< Is it possible to construct WHILE loop that uses an EXISTS function as
the condition?  Something like  - - - >>

EXISTS can only be used in an SQL statement and cannot be used directly in
SQL/PSM.

You can find the new installation here:

http://www.elevatesoft.com/203b13edbdaccs.exe

Please let me know when you have downloaded it.

<< At present I am doing the following:  >>

This should be a bit cleaner:

OPEN tmpCursor;

 WHILE ROWCOUNT(tmpCursor) > 0 DO
   <stuff>
   REFRESH tmpCursor;
 END WHILE;

CLOSE tmpCursor;

http://www.elevatesoft.com/manual?action=viewtopic&id=edb2sql&topic=REFRESH

--
Tim Young
Elevate Software
www.elevatesoft.com
Wed, May 19 2010 5:06 AMPermanent Link

Richard Harding

Wise Nutrition Coaching

Thanks Tim.  Your code was a much neater way of doing the same thing.

<<You can find the new installation here:
http://www.elevatesoft.com/203b13edbdaccs.exe
Please let me know when you have downloaded it.>>

I downloaded the 2.03 b13 DAC-CS installation but I am not sure why I need it.

Richard Harding
Wed, May 19 2010 6:54 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Richard,

<< I downloaded the 2.03 b13 DAC-CS installation but I am not sure why I
need it. >>

Never mind that - it was for someone else and can be ignored.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image