Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to mimic 'NOT EXISTS' in Crystal Reports XI R2 1

Status
Not open for further replies.

SundancerKid

Programmer
Oct 13, 2002
116
US
I have a Report that I want to mimic the NOT EXISTS clause in Crystal Reports XI R2.

I have a Report that uses Business View Manager linked to Oracle 10g database.

I am only using the Main Survey Table Only in my Crystal Report.

If the ProductID Parameter is ...ALL then I want all of the main records selected.

Else

If the ProductID's are selected and they exist in the One to Many Table then the associated main record is valid else do not print.

Main Survey Table (One to One) and SurveyProduct (One to Many) Table both have SurveyID as their common field.

Any Suggestions?
 
Create a parameter and check allow multiple values

Just add filter to select expert,

{ProductID} = {?Param}

Ian
 
Hi Ian,

Thanks for the reply.

So I will have to do a Left Outer Join from my Main Table Survey (One-One) to SurveyProduct (One_Many) table right?

(I am changing a report that already exists and it was only using the Survey Table)

What is happening is I have been rewriting a report that worked fine when it was referenced in a Stored Procedure and it only referenced the Survey Table.

But to get the NOT EXIST clause to work I have to jump thru hoops in Crystal.

They do not like the crappy Prompt screens coming from the Stored Procedure.
 
NOT Exists is couter intuitive to this statement

If the ProductID's are selected and they exist in the One to Many Table then the associated main record is valid else do not print.

This read like an EXISTS

Thus an equal join will return valid records.

If you want records which do not exist in SurveyProduct
then do a left outer, and add to select statement

and isnull(SurveyProduct.ProducyID)

Ian
 
Problem Solved

What I did was I to the Original Oracle View and added the SurveyProduct to the Select statement as a Left Outer Join and then I added the ProductID to the Select.

In Crystal instead of using a detail line I am using a Group on SurveyID so that I get unique SurveyID's.

Since ProductID is now part of the same master record I am able to include or exclude based upon ProductID.

Select Statement used:

(IF '...ALL' in (? ProductID) then
True
Else
IF Q.ProductID = (? ProductID) then
True
Else
False)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top