PRSQL9012005: SELECT * in EXISTS Subquery Returns True

ID Number: Q65412

1.10

OS/2

buglist1.10 buglist1.10a fixlist1.11

Summary:

PROBLEM ID: PRSQL9012005

SYMPTOMS

As long as any rows exist in the table, a WHILE condition should

evaluate to true. As soon as the table is empty, the condition

should evaluate to false. However, the following WHILE condition

returns true on an empty table:

WHILE EXISTS (select * from tablename) ...

WORKAROUND

Any of the following methods will correct this problem:

1. Replace the "*" in the subquery with a valid column name.

2. Add a WHERE clause to the subquery.

3. Use the count(*) aggregate function to check for an empty table.

STATUS

Microsoft has confirmed this to be a problem in SQL Server version

1.1. This problem has been corrected in SQL Server version 1.11,

which is available from Microsoft Product Support Services. For

more information, contact your primary support provider.