June 26, 2008

Faster compilation in Forms Builder

You can speed up the time for a "Compile All", when you close all nodes in the Object Navigator, so that the form shows only the name of the form. Then you press Ctrl+Shift+K for Compile All.


Compile-Times of a normal pl/sql-library with 70 program units


closed nodes : 2 sec
open nodes : 18 sec

Compile-Times of a big pl/sql-library with 130 program units

closed nodes : 2 sec
open nodes : 34 sec

Compile-Times of a medium form with 14 blocks

closed nodes : 3 sec
open nodes : 12 sec

Compile-Times of a big form with 24 blocks and much sourcecode

closed nodes : 6 sec
open nodes : 37 sec



With this little trick you can compile really fast !
try it
Gerd

June 19, 2008

Compile or Compile All ?

What is the best way to compile a form? Before I answer this question here are some explanations:


Compile Incremental : Ctrl + K
Compile All : Shift + Ctrl + K
Compile Module (Generate): Ctrl + T
Run : Ctrl + R

In the older versions of Forms the Compile Module was known as Generate. I prefer this, because the Ctrl+T generates the FMX.

During my daily work I open forms and maintain them. If I use the Ctrl+T to generate the FMX, then Oracle Forms starts implicitly a Compile Incremental before the Generate.

And that's the problem. In 9 of 10 cases the generated FMX is OK, but sometimes the automatical Compile Incremental didn't work properly. It results in non-reproducable errors at runtime.

My solution for this problem is:

After opening a form I start immediately a Compile All. Each Incremental Compile and each Generate now works without runtime-problems.

Try it
Gerd

June 05, 2008

Forms Shutdown

In the article forms-startup I wrote last year how to hide the browser-window, while starting a forms-application. Another problem is: How can we close the browser-window after exiting the forms-application. Here is my favorite solution:

1) Create a new html-file e.g. close.html in your html-directory. This is the main routine, which closes the browser-window.


< BODY onLoad="window.close();" >

2) Set the formsweb.cfg parameter HTMLbeforeForm in the server-directory. This eliminates the security-question "Do you want to close the browser-window".

HTMLbeforeForm=< SCRIPT LANGUAGE="JavaScript" >window.opener = top;< /SCRIPT >

3) The form, which closes the main-application needs a POST-FORM-trigger. /forms/html is a virtual-directory, which points to the close.html.

web.show_document ('/forms/html/close.html', '_self');

Used directories:

< DevSuite-Home > : Your Developer-Suite Home Directory
html-directory : < DevSuite-Home >\tools\web\html
server-directory : < DevSuite-Home >\forms\server
virtual-html-directory : /forms/html defined in forms.conf

Many thanks to Duncan Mills, Frank Nimphius and Richard Squires, who posted this code in the OTN years ago.

Pro) This technique works on IE 6 and IE 7, tested with JInitiator and Sun-Plugin.
Contra) No Firefox-Support. Since Firefox 2.0 it isn't allowed to close a window via JavaScript.

Important: The limitations of this blog forced me to write blanks after each "<" and before each ">". Don't write them, when you use this technique !

have fun
Gerd

June 03, 2008

Sourcecode-Formatting in the OTN-Forum

Nearly each day I see unformatted code in the OTN-Forum. Why?

The problem is, that many poster don't know, how to format sourcecodes. Example:


/*
|| Selecting the sum from all sub-order's
*/
if :control.sub_order_id is not null then
select sum (value)
into :control.sum
from sum_orders
where order_id in (select order_id
from sub_orders
where sub_order_id = :control.sub_order_id
and sub_order_type = 'ONLINE');
else
:control.sum := 0;
end if;
/*
|| now we use the sum in the ...
*/

Who can read that? I love puzzling, but not in sourcecodes. How can we solve this problem?

Use [pre] before your sourcecode and [/pre] after the sourcecode. Then it is readable like your original code:

[pre]
...
if :control.sub_order_id is not null then
select sum (value)
into :control.sum
...
[/pre]

and here is the solution of the above example after using the preformat-tags:

/*
|| Selecting the sum from all sub-order's
*/
if :control.sub_order_id is not null then
select sum (value)
into :control.sum
from sum_orders
where order_id in (select order_id
from sub_orders
where sub_order_id = :control.sub_order_id
and sub_order_type = 'ONLINE');
else
:control.sum := 0;
end if;
/*
|| now we use the sum in the ...
*/

This is readable code at it's best!

Try it
Gerd

June 02, 2008

Open-Form and the Exit-Strategy (2)

Sometimes you use your source-codes since years and think - there is no easier, better and smarter way to do something, like the way in that piece of code.

So here. After writing and testing my last post everything runs well!

Today I refactored some parts of my exit-strategy code and created this much easier solution (normally this is not the goal of refactoring !):

all you need is a

KEY-EXIT in the startform:


COPY ('TRUE', 'GLOBAL.EXIT_IMMEDIATE');
EXIT_FORM (no_validate);

and a WHEN-FORM-NAVIGATE in all other forms

DEFAULT_VALUE ('FALSE', 'GLOBAL.EXIT_IMMEDIATE');
IF :GLOBAL.EXIT_IMMEDIATE = 'TRUE' THEN
EXIT_FORM (no_validate);
END IF;


Now we have a chain reaction, when exiting the startform. Each closing form will let the focus jump to another open form. Then the WHEN-FORM-NAVIGATE triggers and closes this form too. Because the global variable was set to AUTOCLOSE = TRUE.

After the last form the whole application is closed and that's the best way to close an entire application.

If some of those forms started other forms through call_form, then you have to use the WHEN-WINDOW-ACTIVATED, because the WHEN-FORM-NAVIGATE won't trigger while getting the focus.

Isn't that a really easy solution?
Have fun with it
Gerd