1 2 Previous Next 18 Replies Latest reply: Mar 29, 2012 2:57 AM by Gary Graham-Oracle RSS

    Auto recompilation of body after compilation of spec

    Gussay
      SQL Developer 3.1


      If I make a change to my package body (that requires an update to the package spec) but don't compile it, then change my spec, SQL Developer keeps popping up the following warning box...
      Package Body xxx.yyy@my_schema has been externally modified. Reload? 
      (Yes / No boxes) 
      This is annoying.

      How do I stop SQL Developer from trying to automatically recompile my package body and reload the one held in the database after I compile my package spec?


      Gus..
        • 1. Re: Auto recompilation of body after compilation of spec
          rp0428
          >
          How do I stop SQL Developer from trying to automatically recompile my package body and reload the one held in the database after I compile my package spec?
          >
          Your question is a little confusing because of the 'and' in the middle. And there could be things involved you haven't mentioned. So please explain further if it appears that I am not addressing what you intended to ask. I may get it wrong by breaking it in two
          >
          How do I stop SQL Developer from trying to automatically recompile my package body
          >
          It's not clear that a 'recompile' has been attempted yet.
          The warning message is to let you know that the package body that sql developer downloaded may not be the same as what is in the database.
          >
          and reload the one held in the database after I compile my package spec?
          >
          This is the part that (with the first part) could be read two ways. Does it read 'stop sql develoer from doing A and B'; meaning stop sql develoer from reloading the one held in the database? Or do you want to know how to reload the one in the database yourself?

          So I will just try to tell you what I know.
          >
          If I make a change to my package body (that requires an update to the package spec)
          >
          This implies that the change you make to the spec requires a change to the package body. So when the spec is compiled the body will become invalid.
          That is likely the reason for the warning. Sql Developer has detected that the package body, that was valid when it downloaded it, is no longer valid in the database so warns you of that. By itself it doesn't mean that sql develoepr 'recompiled' the package. It may do that automatically, I don't know; I wouldn't expect it to. You could run a simple test to tell for sure it it was important.

          The only package code that will be executed is the code in the database, not package code in an editor window in sql developer. There is only one set of code in the database. If you do execute the package code in an editor window it will be compiled and replace what was in the database and then run the code in the database.

          The only way I know of to avoid the error is to close the window that displays the package body before you change and recompile the package spec.
          • 2. Re: Auto recompilation of body after compilation of spec
            Gussay
            Hi rp0428, thanks for the quick answer.

            sorry my question seems confusing, but i think you got the jist.

            I make the change to the body (say add a new procedure which may take some time) but don't compile this change as I know it will fail without the corresponding change to the spec.... so...
            I change the spec and compile it... (expecting to just switch back to the body and compile that... ) but

            in 3.1, compiling the spec has the effect of refreshing the IDE (you used to have to implicitly select the Package node and right-click / select "Refresh"). That then shows the body with errors AND produces the popup error as described above.

            This did not happen in the older versions of SQL Developer.
            I assumed (my bad for assuming) that this behaviour was something to do with an automatic attempt at a recompile of the body, if it isn't then sorry for the confusion.

            But the issue is still there, I have changed the body, ready for a recompile and the IDE is asking if i want to reload it "because it has been externally modified".
            The body hasn't been externally modified, it's been modified in the IDE ready for recompile... I do NOT want to be asked if i wish to throw away all my changes and not realise that is what I'm being asked.

            It is confusing and annoying and it didn't happen before....

            So i suppose my real question is this... is there any way of stopping SQL Developer checking if what I have changed in the package body in the IDE is the same as what is stored in the database.

            Gus..
            • 3. Re: Auto recompilation of body after compilation of spec
              rp0428
              Thanks for clarifying. I think I understand now but can't find any setting to change the behavior.
              >
              But the issue is still there, I have changed the body, ready for a recompile and the IDE is asking if i want to reload it "because it has been externally modified".
              The body hasn't been externally modified, it's been modified in the IDE ready for recompile... I do NOT want to be asked if i wish to throw away all my changes and not realise that is what I'm being asked.
              >
              The actual cause though is probably what I mentioned; recompiling the package spec makes the body invalid and sql developer detects this and asks about reloading.

              You can test this by checking the VALID/INVALID status of spec and body before, during and after your change
              select created, last_ddl_time, status
               from dba_objects
                where object_name = myPackageName
              You can always use a plain sql editor to modify your package body and a refresh of the package in the tree won't affect your code there. It is only if you edit the code displayed when you have selected the body in the nav tree that would get replaced on a reload.

              I agree that would be a simple mistake to make and have your new code wiped out.
              Can't help you with any setting to change the behavior.

              Have noticed that Gary Graham, from the sql dev team, posts frequently. Maybe he can respond to the setting issue.
              • 4. Re: Auto recompilation of body after compilation of spec
                Gussay
                Yes, you are right, recompiling the spec makes the body invalid and it asks about reloading the invalid body.

                In fact, try this...
                take a compiled package body, add a space to it but don't compile...
                add a space to the package spec, recompile the spec, the body becomes invalid in the packages tree node AND you get the do you want to reload

                Why the invalid, why the reload?

                This is a bug IMHO.


                Thanks for your efforts

                Gus..

                Edited by: Gussay on Mar 27, 2012 11:39 AM
                • 5. Re: Auto recompilation of body after compilation of spec
                  rp0428
                  >
                  Why the invalid, why the reload?
                  >
                  Not a bug -that's the way it has always worked.

                  The BODY depends on the SPEC so if you modify the spec and recompile it the BODY needs to be recompiled also.

                  Note that if you only modify the BODY and recompile the body it will not invalidate the spec or the objects dependent on the spec.

                  The reason you are ask about 'reload' is to alert you to the fact that the DB version of the package is different than what you see in the tree (and possibly an editor). It gives you an opportunity to save your editor contents if you want before they are replaced when you choose to reload.
                  • 6. Re: Auto recompilation of body after compilation of spec
                    Gussay
                    No, not true on all counts here.
                    Please re-read my previous post.

                    1. it isn't the way it has always worked.

                    2. Adding a SPACE, or a comment to your spec and recompiling should NOT AUTOMATICALLY INVALIDATE the body of your package.
                    If you go into SQLPlus and add a space or a comment to your package spec, does that invalidate the package body?
                    I don't think so.
                    Therefore something is assuming "because you have recompiled your spec, your body is now invalid"

                    3. Modifying the body and compiling it BEFORE modifying the spec (when a modification is required) will always give you compilation errors on the body.

                    Therefore you compile the spec first, which should just compile , like it always did.
                    SQL Dev should not go on to check if your body is broken, popup a message that is prompting you to reload the version which is broken (losing all the changes you have just made), and all that BEFORE you have a chance of compiling what should be the new correct body.
                    Previous versions of SQL Developer did not do this extra process and certainly DID NOT did not bring up the "externally modified" warning.... I've been using SQL Developer since Raptor.

                    3.1 does produce these problems, which is a backwards step.
                    Therefore it is a bug.
                    • 7. Re: Auto recompilation of body after compilation of spec
                      rp0428
                      >
                      1. it isn't the way it has always worked.
                      >
                      I'm referring to Oracle invalidating the package body if you change the spec and recompile. I wasn't talking about SQL Developer.
                      >
                      If you go into SQLPlus and add a space or a comment to your package spec, does that invalidate the package body?
                      I don't think so.
                      >
                      Well test it, like I did, and maybe you will think differently.
                      >
                      Therefore it is a bug.
                      >
                      You can always report bugs to Oracle.
                      • 8. Re: Auto recompilation of body after compilation of spec
                        Gussay
                        Please look at the heading of this forum.
                          » Application Development in PL/SQL » SQL Developer (Not for general SQL/PLSQL questions)
                        Have I not posted this to the SQL Developer forum?

                        Am I not supposed to highlight what I think may be bugs in SQL Developer here?

                        I am searching for a solution to a bug I am experiencing in SQL Developer, is there anyone from the dev team who can shed any light on this?

                        Gus..
                        • 9. Re: Auto recompilation of body after compilation of spec
                          Gary Graham-Oracle
                          Hi Gus,

                          To respond to your original post, in my opinion, I would say SQL Developer's code editor is working as-designed. If you do not wish to see the Reload? warning, just uncheck the Tools|Preferences|Environment|Automatically Reload Externally Modified Files box.

                          For whatever reason, though, some may prefer to leave the box in a checked off state in order to receive the warning.

                          This is the behavior in that case...
                          1. Edits to both the spec and body may occur without the Externally Modified Files warning popping up if no compile/save is requested.
                          2. Edit + compile/save of the spec without a corresponding change to the body produces an error in the Message - Log pane.
                          3. Edit of body + edit of spec + compile/save of spec produces the Externally Modfied Files warning for the body.
                          4. To avoid the annoyance of losing any body edits, be careful to answer No to the Reload? prompt.

                          Regards,
                          Gary
                          SQL Developer Team
                          • 10. Re: Auto recompilation of body after compilation of spec
                            Gussay
                            Thanks for the reply Gary, and before I start the whinge, may I say I'm a big fan of SQL Developer and a big thank you to you and the team.

                            But the pedant (hey, I'm a developer too) in me says...

                            Scenario 3 above
                            3. Edit of body + edit of spec + compile/save of spec produces the Externally Modfied Files warning for the body.
                            ... is a fairly standard way of developing code. Previously, when executing this scenario, I got no popup message. Now I do.

                            So I will be turning the Automatically Reload off as you've suggested as the popup is becoming very annoying. (UPDATE: This required a re-start to take effect)


                            To Quote the SQL Developer help..
                            Automatically Reload Externally Modified Files: If this option is checked, any files open in SQL Developer that have been modified by an external application 
                            are updated when you switch back to SQL Developer, overwriting any changes that you might have made. If this option is not checked, 
                            changes that you make in SQL Developer overwrite any changes that might have been made by external applications
                            And just to be clear, when executing scenario 3...

                            Is SQL Developer seeing the Oracle DB as the external application that has made the changes to the body of the package?
                            OR
                            Is SQL Developer seeing itself as the external application that has made the changes to the body of the package?
                            OR
                            Is SQL Developer just seeing a difference and popping up this warning?

                            Also which, between Automatic Reload and Point at which there is a Check to see if the body in Window is still the same as DB version, is the new feature in 3.1?


                            Once again, loving your work

                            Regards,

                            Gus..

                            Edited by: Gussay on Mar 28, 2012 11:04 AM
                            • 11. Re: Auto recompilation of body after compilation of spec
                              archimede
                              Gussay wrote:
                              take a compiled package body, add a space to it but don't compile...
                              add a space to the package spec, recompile the spec, the body becomes
                              invalid in the packages tree node AND you get the do you want to reload
                              Sorry, I don't get it: I tried the above procedure and, while the body does become invalid, I do not see any popup asking to reload (Tools|Preferences|Environment|Automatically Reload Externally Modified Files is checked here).

                              Are you working with external files or directly modifying the db objects?

                              Alessandro
                              • 12. Re: Auto recompilation of body after compilation of spec
                                Gussay
                                Alessandro
                                I'm running from the pinned package body object and pinned package spec object in the IDE (as described in Gary's scenario 3).

                                Are you running 3.1?
                                If you are, I'd like to know how you are getting that behaviour, which is what I used to have but don't any more...

                                Regards,
                                Gus..

                                UPDATE: I just found that when changing the Automatic Reload setting required a restart to work.
                                This may be the difference.

                                Edited by: Gussay on Mar 28, 2012 11:05 AM
                                • 13. Re: Auto recompilation of body after compilation of spec
                                  archimede
                                  Not sure what "pinned" means but yes, I'm on SQLDev 3.1.07.42, Fedora 15 and Java 1.6.0_30.

                                  AFAIR it's always worked that way and I didn't change any settings lately, so I'm afraid I can't help you get the same behaviour. Hopefully someone of the team will shed some light on this.

                                  Alessandro
                                  • 14. Re: Auto recompilation of body after compilation of spec
                                    Gussay
                                    Alessandro

                                    Yes, I'm running the same version (3.1.07.42) with the Java that shipped with it (1.6.0_11) and Windows 7.

                                    AFAIR, the way yours is performing is always the way I remember it working too! To coin a phrase... I was as happy as Larry!

                                    Pinned just means the window is pinned, i.e the little red drawing pin holds the object window in place, i don't think that is significant but thought I'd mention it.
                                    1 2 Previous Next