Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Conditional Left join Post Reply Post New Topic
Author Message
cfok
Newbie
Newbie


Joined: 28 Aug 2009
Online Status: Offline
Posts: 3
Quote cfok Replybullet Topic: Conditional Left join
    Posted: 28 Aug 2009 at 12:50pm
Hi there,

Does anyone know if it's possible to do a conditional left join in Crystal?
Example,
select * from A left outer join B on (A.id = B.id and B.colA = '5')

If it's not supported, does anyone know of any tricks to accomplish the same thing?

Thanks!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Aug 2009 at 1:10pm
You should be able to do that as a Command. Although not all datasource types support commands.
If you are coming from a SQL source you can create a view or stored proc in teh DB and use that as the datasource as you would a table.
IP IP Logged
cfok
Newbie
Newbie


Joined: 28 Aug 2009
Online Status: Offline
Posts: 3
Quote cfok Replybullet Posted: 28 Aug 2009 at 1:21pm
Thanks for the reply! The only problem is the a Command does a full table lookup and does not filter out my records specified in the Record Selection (it does it in memory instead of at a database level).  We had a lot of performance issues with the use of commands.

The other problem with a view is that the conditional filter is dynamic, meaning that it's not going to be B.colA = '5', but more like B.colA = :PARAM
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Aug 2009 at 1:28pm

Can you go with a stored proc?

You can create the param in the SP, use the SP as the source, crsytal will create a interface for teh param to be passed back to the source and run theSP at the time of the report generation which should greatly improve performance and address the param issue. 
IP IP Logged
cfok
Newbie
Newbie


Joined: 28 Aug 2009
Online Status: Offline
Posts: 3
Quote cfok Replybullet Posted: 28 Aug 2009 at 2:45pm
Unfortunately, our application has over 300 tables which now needs this left conditional join so stored proc is most likely not an optimal solution for us.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Aug 2009 at 3:09pm
I am out of ideas on this.
Perhaps Hilfy or Lockwelle will read this an chime in...
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.032 seconds.