• Login

DataSoft Corporation


The EXISTS keyword tests whether rows exist in the result of a subquery. True is returned if the subquery contains any rows.

For every row the outer query evaluates, Pervasive PSQL tests for the existence of a related row from the subquery. Pervasive PSQL includes in the statement's result table each row from the outer query that corresponds to a related row from the subquery.

You may use EXISTS for a subquery within a stored procedure. However, the subquery SELECT statement within the stored procedure may not contain a COMPUTE clause or the INTO keyword.

In most cases, a subquery with EXISTS can be rewritten to use IN. Pervasive PSQL can process the query more efficiently if the query uses IN.


The following statement returns a list containing only persons who have a 4.0 grade point average:

(SELECT * FROM Enrolls e WHERE e.Student_ID = p.id 
AND Grade = 4.0)

This statement can be rewritten to use IN:

SELECT * FROM Person p WHERE p.id IN 
(SELECT e.Student_ID FROM Enrolls WHERE Grade = 4.0)
Thursday, 18 April 2019 Posted in Pervasive SQL Command
   Knowledgebase  Contact Us
 Sitemap  Privacy Policy
    Customer Service

Copyright © 2020 DataSoft Corporation All rights reserved.