1 2 Previous Next 21 Replies Latest reply on Dec 26, 2012 8:53 PM by lhallberg

    Global Fields and computed values

    tnfink

      I encountered a (at least for myself) surprising behavior:

       

      I have a table called Project with a global field called ReportYear.

      I have a table called Employee with a computed global field also called ReportYear. The computation just copies the value from Project.ReportYear.

       

      The motivation for this is that I use the value in ReportYear to define relations used for reports.

       

      What surprises me is that

      - a change in Project.Reportyear

      - does not cange the value in Employee.ReportYear

      .

       

      It seems that the value in Employee.ReportYear is computed only once when initiating the session. There seems to be no automatic updates.

       

      Can anybody confirm this assumption?

       

      If yes, Is there a way to update the computation?

       

      Thanks for any help!

        • 1. Re: Global Fields and computed values
          ByteTheBullet

          How do you have Employee.ReportYear defined? Is it set as a calculation, or an auto-enter number? If it's an auto-enter calculation, do you have the checkbox to not replace existing values unchecked? If it's a calculation, do you have it defined as Evaluate(Project::ReportYear)? Also if it's a calculation, do you it set to store the value?

          1 of 1 people found this helpful
          • 2. Re: Global Fields and computed values
            schiang

            Recalled my previous case. I used a computed global field as "Get(currentdate)".

            I want this global field always pointing to the records of today. then I realized that the computed global field will not be triggered automatically

             

            Steven

            • 3. Re: Global Fields and computed values
              comment

              tnfink wrote:

               

              I have a table called Project with a global field called ReportYear.

              I have a table called Employee with a computed global field also called ReportYear. The computation just copies the value from Project.ReportYear.

               

              1. A calculation field that references a global field needs to be unstored ( i.e. not global).

               

              2. In this case, the calculated field in the Employee table is entirely redundant. You can simply use the global field in Project directly (global fields are available from anywhere, even without a relationship).

              • 4. Re: Global Fields and computed values
                tnfink

                Employee.ReportYear is a calculation (in my German version a "Formel"). It is not an automatically generated value.

                 

                The calculation expression is just

                  Project :: ReportYear

                I added an

                  Evaluate()

                around it. No changes. The expression seems to work in principle, because it copies the value. It is just not updated.

                 

                If I try to set the flag to "not store the value" it removes the flag for global storage.

                 

                Hm, if if do not use it as global value, it would be duplicated for every entity, but could still be used for relations.

                .. testing ...

                 

                This seems to work, thanks a lot for the hints!

                • 5. Re: Global Fields and computed values
                  tnfink

                  In your case, I could somehow understand that it is hard for the database system to know when to update. But, in my case, I actually change 1 global value and would expect that all dependent values would be updated automatically.

                   

                  But most probably, you are right and it is the same lack of update support for global values.

                  • 6. Re: Global Fields and computed values
                    tnfink

                    ad 1.

                    You are right, see my comment above.

                    Does this means global values are always stored and not updated automatically at all?

                     

                    ad 2.

                    I had to duplicate the value because I needed it to define a relationship. As far as my experiences with FileMaker go, a relation definition can only use the fields of the associated tables.

                    • 7. Re: Global Fields and computed values
                      comment

                      tnfink wrote:

                       

                      Does this means global values are always stored and not updated automatically at all?

                       

                      Global calculation fields are always stored.

                       

                       

                       

                      tnfink wrote:

                       

                      I had to duplicate the value because I needed it to define a relationship.

                       

                      OK, that makes sense - as long as the field is on the "left side" of the relationship. Then it doesn't matter if it's global or unstored. Of course, you want it to be unstored, so that it recalculates as needed.

                      • 8. Re: Global Fields and computed values

                        That is not correct. Storing the result of a global calculation makes no sense as its value changes with the result of the calculation. It can not be indexed and not used as secondary key field. It can not be used in an other calculated field that must be stored and indexed. In fact it behaves exactly like an unstored field, hence I would say it is always unstored.

                         

                        Winfried

                        • 9. Re: Global Fields and computed values
                          DavidJondreau

                          Seems we need to be sure everyone's operating from a common definition of the term "stored". The simplest answer is that "unstored" fields are calculations that have had the "do not store calculation results..." checkbox checked. By this definition global calculations are stored. Another definition may be, if the database were closed, does the data exist? I'm not sure about the answer to that one.

                           

                          Non-global calculation fields can be stored, yet their values will change with the result of the calculations. And, keep in mind, there's a difference between stored and indexed. It's true that global fields can't be indexed. (Should that be part of the definition of whether it is "stored"?) The reason is can't be used as a child key field is the indexing issue. You can prohibit indexing of a stored field and the relationship won't work.

                          • 10. Re: Global Fields and computed values
                            comment

                            Winfried Huslik wrote:

                             

                            In fact it behaves exactly like an unstored field

                             

                            Then why does the OP have a problem with it? The fact is that an unstored calculation will not retain its value when the referenced field in the other table has been modified, the way the global (stored) calculation does. That is very far from behaving the same.

                            • 11. Re: Global Fields and computed values
                              comment

                              DavidJondreau wrote:

                               

                              Seems we need to be sure everyone's operating from a common definition of the term "stored". The simplest answer is that "unstored" fields are calculations that have had the "do not store calculation results..." checkbox checked.

                               

                              I was of course referring to this meaning and no other. I would choose another term if I were discussing another feature. Perhaps it would be better to be even more explicit and use only the term "unstored", and instead of saying that global calculation fields are always stored, one would say that a calculation field can be either global or unstored - never both.

                               

                               

                              I would add that the term "store" in this context has nothing to do with "save" in the context of what exists on the disk when the file is closed. Quite simply, a calculation field has two "slots"  - one for keeping the formula, and one for the value resulting from the most recent evaluation.

                               

                              An unstored field will not have anything in the value slot, ever. Any reference to it must re-evaluate the formula anew - whereas a reference to a "stored" field will simply retrieve the value kept in the value slot.

                              • 12. Re: Global Fields and computed values

                                Hi Winfried,

                                 

                                Globals, including global calculations - by their nature - are stored.  If you do not believe Michael (and you should) then maybe you will believe Ray Cologon, PhD. aka CobaltSky.  I would prefer to give the exact link but it won't come up.  But attached is the document from which he clearly states in his second paragraph that global calculations are stored.  :^)

                                 

                                BTW, I am confident that I could find many more links where Ray has mentioned that global calculations are stored as well ... one on Cafe' comes to mind quite clearly but I think one such link should suffice.

                                • 13. Re: Global Fields and computed values
                                  BruceRobertson

                                  Ray Cologon's answer was written in 2005 and is not exactly correct. It is incomplete.

                                   

                                  He states "Thus when the database is hosted, the calc you mention will show the value it held when the database was last closed on a host computer..."

                                   

                                  As many discussions have indicated since that time, a global also can aquire a new value when set by a server-side script. Anybody starting a new connection to the database after the server side script has run will see the new value.

                                  • 14. Re: Global Fields and computed values

                                    I realize the date Bruce.  I am pointing only to the reference that global calculations are stored and not other discussions which might have taken place in that thread because, as you say, behaviors change through the years.  But ...  server-side script didn't even exist then.

                                     

                                    Global calculations are stored and that has not changed.  :^)

                                     

                                    Michael explained it very well.

                                    1 2 Previous Next