Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Parameter in nested SELECT Post Reply Post New Topic
Author Message
ccc2
Newbie
Newbie


Joined: 09 Oct 2013
Online Status: Offline
Posts: 3
Quote ccc2 Replybullet Topic: Parameter in nested SELECT
     Posted: 15 Oct 2013 at 4:36am
Hello,
 
I'm working on a report which uses a Command Object which has a nested SELECT statement.
 
In the outer SELECT, I am calling a parameter which is a dynamic list called client_names. In the inner select I'm calling a parameter that is a statically entered value that represents the fiscal year.
 
For example, the SQL in the command object looks similar to this:
 
SELECT client_no, client_name, client_address, client_status
FROM
CLIENTS
WHERE
client_name = {?client_names}
AND client_no NOT IN (
  SELECT client_no FROM another_table
  where fiscal_year = {?fiscal_year}
)
 
The issue that I'm running into is that when the inner select uses the {?fiscal_year} parameter the dynamic list for client_names doesn't get populated. If I remove the {?fiscal_year} parameter and replace it with the year 2012, {?client_names} gets populated as expected.
 
I've tried searching on these forums and the SAP forums for others that have had this issue, but I can't seem to find anything. Any ideas as to what would be causing this?
 
Thanks


Edited by ccc2 - 15 Oct 2013 at 4:37am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 15 Oct 2013 at 5:10am
I have no idea if this would help, but have you thought of trying this type of sql:

select ....
from clients as c
left join (select client_no from another_table
            where fiscal_year = {?fiscal_year}) as ano
    on ano.client_no = c.client_no
where ano.client_no is null
and client_name = {?client_names}



I have no idea if it will work.

I have a general theory about the command object...I think that it was designed to populate dynamic parameters and not be the source of the report...which might be why we are seeing this.

I know that many reports use the Command Object as a datasource for various reasons, all of which are valid...I just don't think that it was designed to that and so fails in some circumstances....

and I've been wrong before

HTH

IP IP Logged
ccc2
Newbie
Newbie


Joined: 09 Oct 2013
Online Status: Offline
Posts: 3
Quote ccc2 Replybullet Posted: 15 Oct 2013 at 5:27am
Lockwelle, thanks for the reply. I'll see if I can restructure my SQL statement and then test.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 15 Oct 2013 at 9:58am
It sounds like the problem is that you are using the same command for both the report AND the dynamic prompt. Here's what I would do:

1. Leave the existing command as-is. Use this for the data in the report ONLY.

2. Create a new command that only returns the name information that you need for the dynamic prompt. Hook up the prompt to this table. DO NOT join this to the other command! Crystal will throw a warning about this - ignore it.

Doing it this way, you won't run into the issue where the dynamic prompt requires the additional parameter. This is one of the few times when you can actually combine multiple commands in a single report without affecting performance. Just make sure that all of the data on the report comes from the main command and NOT the command created for the dynamic parameter.

-Dell
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 15 Oct 2013 at 12:51pm
Thanks Dell,

I didn't realize that ccc2 was trying to populate a dynamic list AND the main report off of one command
IP IP Logged
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