I have three tables: User_role, users, provider.
In the users table, column provider_id can be null. Obviously, these are subsets
of the real tables.
User_role
role_id | description
1 | Admin
2 | SysAdmin
3 | Private
4 | General
users
user_id | role_id | provider_id
1 | 4 |
2 | 2 |
3 | 1 |
4 | 4 |
5 | 2 |
6 | 1 |
7 | 4 |
8 | 3 | 21
9 | 3 | 22
10 | 3 | 23
11 | 3 | 24
12 | 3 | 25
provider
proider_id | Provider_lastName | Provider_FirstName
21 | Kates | Fred
22 | AlastName | FirstName
23 | Kmart | Al
24 | Fantaz | Taz
25 | Nelson | Kirk
26 | Marino | Dan
Here is the sql. This works fine.
select
user_role.role_id,
user_role.DESCRIPTION,
users.user_id,
users.Role_Id,
users.provider_id,
provider.provider_id,
provider.provider_lastName,
provider.provider_FirstName
from
users
inner join user_role
on users.user_id = user_role.ROLE_ID
left outer join
provider
on users.PROVIDER_ID = provider.PROVIDER_ID
order by users.user_id
The end user can select a user_role and provider. The business logic
is:
1. If end-user selects role_id 3, All fields are to be displayed corresponding to the provider_id selected.
2. If end-user selects role_id 1,2, or 4. The query doesn't worry about the provider_id. The provider.provider_id,provider.provider_lastName,
and provider.provider_FirstName will be null, and all remaining fields will be returned.
Problem:
The end-user selects User_role 1 and 3 and provider_id 21 and 23. The Crystal report should report
all Users with a role_id as 1 and all role_id with 3 and provider of 21 or 23.
Is this possible in Crystal? I know it's possible with SQL and Java; I've done it before.
------------------------------------------------------------------
//1. I have to and it to the providerID
if Count({?userRoleId}) = 1 and {?userRoleId} = 3
then
{Command.ROLE_ID} = {?userRoleId} and
{Command.PROVIDER_ID}={?providerId}
//2. If 3 is not in the userRoleId
else if {?userRoleId} <> 3 then
{Command.ROLE_ID} = {?userRoleId}
//3. SQL not working the problem.
else
{Command.ROLE_ID} = {?userTypeId} or
{Command.PROVIDER_ID}={?providerId}
----------------------------------------------------------------
How does Crystal work?
Does it build the SQL every iteration?