What is the benefit of Enforce Join option in Crystal Reports?
Asked Answered
M

2

6

What is the benefit the makes SAP Crystal reports Enforce Join default option in Link Dialog is "Not Enforced"?

Is it performance issue? because I noticed if you don't select field from the joined table it'll generate SELECT query with only fields of the selected Table only without any joins.

here's some information about the Enforce Join options:

  • Not Enforced: When you select this option, the link you've created is used only if it's explicitly required by the Select statement. This is the default option. Your users can create reports based on the selected tables without restriction (that is, without enforcement based on other tables).

  • Enforced From: When you select this option, if the "to" table for the link is used, the link is enforced. For example, if you create a link from Table A to Table B using Enforce From and select only a field from Table B, the Select statement will still include the join to Table A because it is enforced. Conversely, selecting only from Table A with the same join condition will not cause the join to Table B to be enforced.

  • Enforced To: When you select this option, if the "from" table for the link is used, the link is enforced. For example, if you create a link from Table A to Table B using Enforce To and select only a field from Table A, the join to Table B will be enforced, and the Select statement that is generated will include both tables.

  • Enforced Both: When you select this option, if either the "from" table or the "to" table for this link is used, the link is enforced.

Meara answered 25/5, 2011 at 10:27 Comment(0)
G
9

The "enforced" part is used to FORCE the inclusion of tables that contain fields that are NOT used in the report/select conditions.

Well crap, that's what you said.

My understanding:

If you have two tables (tbl_A, tbl_B) w/ a link-able field, and you don't USE any field from the second table, it can be dropped from the select, and the "regular" effects of the join may disappear.

Select 
   'You're account is in default!' as Message,
   tbl_A.full_name, tbl_A.street_address, tbl_A.city, tbl_A.blah_blah
From
   all_customers tbl_A, 
   delinquent_accounts tbl_B
Where
   tbl_A.account_no = tbl_B.account_no

Without the enforced join, might wind up as

Select 
   'You're account is in default!' as Message,
   tbl_A.full_name, tbl_A.street_address, tbl_A.city, tbl_A.blah_blah
From
   all_customers tbl_A, 

In other words, you might wind up setting dunning letters to your whole customer base instead of just the delinquent accounts. (Which is why we test reports before implementing them, I guess).

Grandmother answered 25/5, 2011 at 19:41 Comment(3)
Interesting idea, I've wondered for years what "enforced" meant (I always ignored it). So, why would Crystal even bother coding this as an option, anyway? Based on your description, it sounds like an unnecessary option that occasionally protects bad SQL writers from their own mistakes and sometimes creates errors for good SQL writers with clever code.Uranus
Well.... remember, CR has been around for a couple decades (?) and many of their less-thought-of "features" are still around. Just a thought. BTW, that particular one has bitten me before. OH! Another REALLY painful bite: CR will "help" you by putting links into your sub-reports if you have your own links going to formulas. That one REALLY hurts.Grandmother
Yeah, given the potential for error with the unenforced ones, it seems necessary to get into the habit of immediately changing all links to "Enforced Both". At least that's what I (try to) do. I don't see a use for unenforced joins, other than laziness at the expense of opening a whole new category of potential errors.Horsehair
L
0

To make things simple

If you use Enforce From As if Table 1 is use whether u actually use table 1 or not.

If you use Enforce To As if Table 2 is use whether u actually use table 2 or not.

if you use Enforce Both As if Both Table 1 and 2 are use whether either or both of them is use or not

if you use NOT ENFORCE enforcement of link will only be established if the table is use

Ludie answered 14/12, 2023 at 2:12 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.