Posted By: dthibi Compile only SPEC or BODY in Program Window - 09/11/17 10:03 PM
In the Program Window, is there a way to only compile the Package Spec or Package Body?

For example if I have file mypackage.pck:

SQL Query
set DEFINE OFF

create or replace package PKG_TEST is

end PKG_TEST;
/
create or replace package body PKG_TEST is

begin
  null;
end PKG_TEST;
/

SHOW ERRORS

The Program Window splits it into 3 tabs Spec, Body, and "?". When I compile I get an error because of the "SHOW ERRORS" at the end. Can I make this work?

You cannot compile just the spec or body. You would have to keep them in separate files.

To suppress the "SHOW ERRORS" SQL*Plus command, you can go to Preferences > Program Window and enable the "Ignore unrecognized PL/SQL" option.
To compile only Spec or Body you can use the 'Compile Current' plug-in from BAR Solutions (it's on the plug-in page). Works like a charm.
Thanks for the plug ;-)
I like a combo of both solutions with some additional preference setup:

1) I downloaded plug-in "Execute Current Statement" (new name for "Compile Current"?)

2) Set the following preferences:
  • Window Types:
    • Program Window -> Ignore unrecognized PL/SQL
    • AutoSelect statement
  • User Interface -> Key Configuration
    • SQL Window: Execute current statement: Ctl+F8
    • Plug-Ins / [ExecuteCurrent] ... / Execute current statement: Alt+F8
    • Plug-Ins / [ExecuteCurrent] ... / Execute current tab: Shift+F8

I now have the following behavior:

F8: run statement under cursor in SQL Win, compile all in Pgm Win
Ctl+F8: run all in SQL Win, n/a in Pgm Win
Alt+F8: run statement under cursor in SQL Win, n/a in Pgm Win
Shift+F8: n/a in SQL Win, compile only current tab in Pgm Win

Patrick, since "Execute current statement" seems to only apply in the SQL Win and "Execute current tab" only applies in the Pgm Win, could you combine both into 1 command that takes the appropriate action for the window your in?

I tried setting both to the same hotkey and that didn't work (darn!)
I added a new command to the plugin to execute the current window. This executes the current statement or the current tab, depending on the windowtype.
© Allround Automations forums