1 2 Previous Next 15 Replies Latest reply: Nov 10, 2008 12:13 PM by Andreas Weiden RSS

    Get_record_property

    642302
      Hi all.

      I've a form for filling the establishment datas like, estab_cod, estab_name, estab_add, phone and so on.

      If the user changes some information a window comes up when the key-commit is pressed so that the user explain why. All the informations are saved in the log table called 'estab_log' in which there's a column 'log' that is added 1 to control it.

      I was working with Global Variables making comparison among them after 'key-next-item' trigger, but it is so hard.

      I've tryied to use the get_record_property in the key-commit trigger in the block level so that call my 'update_log' trigger, but it didn't worked out 'cause always the cursor is in the field due to the user navigation, Forms 'understands' that the record has been changed and then it's saved again in the log table.

      Is there any way to solve it?

      Regards,


      Anderson

      Edited by: AS_Anderson on Nov 4, 2008 8:55 AM
        • 1. Re: Get_record_property
          Andreas Weiden
          I'm not quite sure want you want to achieve. I'll try anyway:

          1. Every time the user changes some data in a record, you force him to enter an explanation in a textbox.
          2. This explanation should be saved in a log-table when the record itself is saved.

          so far, so good, but..

          What does not work?
          What do you want to achieve with the KEY-NEXTITEM-trigger?
          What do you want to achieve with the global?
          What is that about the GET_RECORD_PROPERTY-call in KEY-COMMIT?
          • 2. Re: Get_record_property
            642302
            Hi, aweiden.

            Thanks for your help.

            Actually, my application has already a window that forces user to provide the change reason. Although, it has been fired when forms is committed.

            When I say that it does not work, it means that Forms 'understands' that field was changed even by user navigation.

            For example, if user executes the query the GET_RECORD_PROPERTY built-in gets the status = 'changed' even though there's no changing. Please see below:

            -- QUERY
            BEGIN
            ENTER_QUERY;
            EXECUT_QUERY;
            GO_ITEM('ESB_COD'); /* Focus on the field now.
            But if I check the Record_Status in this time is Changed
            due to the Focus on the field */
            END;

            --TRIGGER KEY-COMMIT:
            BEGIN
            IF GET_RECORD_PROPERTY(1,'ESB_COD',STATUS) = 'CHANGED'
            THEN
            GO_BLOCK('CHANGING');
            GO_ITEM('CHANG_REASON');
            END IF;
            COMMIT;
            END;

            I hope to have been more clear.
            Thank you, again.

            Regards,

            Anderson
            • 3. Re: Get_record_property
              Andreas Weiden
              if the recordstatus is changed just after the query there is normally some cros validation occuring from reading lookup values in the POST-QUERY.

              Do you have a POST-QUERY-trigger on your block? If so, issue a
              SET_RECORD_PROPERTY('BLOCK', TO_NUMBER(:SYSTEM.TRIGGER_RECORD), STATUS, QUERY_STATUS);
              at the end of it. Then the recordstatus should keep QUERY until a "real" change occurs
              • 4. Re: Get_record_property
                642302
                Yes, I do. I've just done as you've told me. But it lifts the ORA-6502 error at run-time.
                I'll check what is going wrong.
                • 5. Re: Get_record_property
                  Andreas Weiden
                  uups,

                  i put the parameters in the wrong order, should read:
                  SET_RECORD_PROPERTY(TO_NUMBER(:SYSTEM.TRIGGER_RECORD), 'BLOCK', STATUS, QUERY_STATUS);
                  • 6. Re: Get_record_property
                    642302
                    Thank you, again.

                    I'm gonna try it and I'll let you know.
                    • 7. Re: Get_record_property
                      642302
                      Hello.

                      I've done it again and now it is almost working well, 'cause it is only work well if the I user does not press the enter key or navigte to other field of the form.
                      As the user navigates to other field the block status is altered to 'changed'.
                      • 8. Re: Get_record_property
                        user346369
                        Tell us what triggers are running when user navigates to next field. Is there a key-next-item trigger that changes something? Is there a when-validate-item or post-text-item trigger that sets a value in your record? Look for a when-new-item-instance trigger, too.

                        Those things are what cause record status to become "CHANGED" when you navigate to another field.
                        • 9. Re: Get_record_property
                          642302
                          I have WHEN-VALIDATE-ITEM in my 1st field(estab_cod) just to check if the estab_cod>0. KEY-NEXT-ITEM is just to populate the other forms fields.
                          Note: In the other forms fields - trigger K-N-I, I just put 'next_item'.
                          There's no other code for the fields.
                          In the block level, there's KEY-COMMIT and POST-QUERY - where I put the code SET_RECORD... as issued above.


                          Anderson
                          • 10. Re: Get_record_property
                            Andreas Weiden
                            I have WHEN-VALIDATE-ITEM in my 1st field(estab_cod) just to check if the estab_cod>0.
                            If there is no assignment in this trigger, it should not be a problem
                            KEY-NEXT-ITEM is just to populate the other forms fields.
                            This sounds like it could cause the problem, please post the code (generally this logic "populating the other forms fields" should also be in WHEN-VALIDATE-ITEM-triggers, for it should be executed only if the field value changes and not for every navigation).
                            Note: In the other forms fields - trigger K-N-I, I just put 'next_item'.
                            If just a next_item in the the KEY-NEXT-ITEM-trigger, then delete it for this is the default-functionality.
                            • 11. Re: Get_record_property
                              642302
                              Here is the sample Code:

                              BEGIN
                              SELECT column1, column2,...columnN
                              INTO form_field1, form_field2...form_fieldN
                              FROM ESTAB_TABLE, CITY_TABLE, STATE_TABLE, COUNTRY_TABLE
                              WHERE (estab_cod = :form_estab.esb) AND
                              (TABLE JOINS)
                              EXCEPTION
                              WHEN NO_DATA_FOUND THEN
                              CLEAR_FORM;
                              GO_ITEM(:form_estab.esb);
                              END;
                              • 12. Re: Get_record_property
                                Andreas Weiden
                                are the form_fields in the INTO-clause fields in the same block ? If so, you have your error-cause.. When has this code to be executed? When the user changed the value of the current item? If so, put the code into the WHEN-VALIDATE-ITEM-trigger. If it could be read immediatly after the query it should be in the POST-QUERY-trigger.
                                • 13. Re: Get_record_property
                                  user346369
                                  AS_Anderson wrote:
                                  Here is the sample Code:

                                  BEGIN
                                  SELECT column1, column2,...columnN
                                  INTO form_field1, form_field2...form_fieldN
                                  FROM ESTAB_TABLE, CITY_TABLE, STATE_TABLE, COUNTRY_TABLE
                                  WHERE....
                                  In Forms, that is not the correct way to populate data into a block. You need to use Execute_Query instead. Forms automatic processing creates and executes the query in the background.

                                  It sounds like you want to populate data from the ESTAB_TABLE after the user enters a key value in :form_estab.esb

                                  What you really should do is create two blocks, on a control block (I usually name it B1), and then your FORM_ESTAB base-table block.

                                  Create the field ESB in block B1. When the user enters a value in B1.esb, you could then have a key-next-item trigger that does this:

                                  Go_block('FORM_ESTAB');
                                  Execute_Query;

                                  In the Form_estab block, put a where clause:

                                  estab_cod = :B1.esb AND (TABLE JOINS)
                                  • 14. Re: Get_record_property[SOLVED]
                                    642302
                                    Thank you.


                                    As you had told me, there was values attribution in some triggers which then modified the block status.
                                    Actually, it was a new situation for me due to this new project.
                                    Thanks for your help.

                                    Taking advantage to this opportunity, do you know some good book to Oracle Forms Developer?
                                    I've performed the Oracle 10g Forms and Reports Courses in an Oracle Official, but I rather need to improve my knowledges and start in a advanced code for this project; using, for example, dynamic sql in forms.

                                    Thank you.

                                    Best Regards.
                                    1 2 Previous Next