October 12, 2005

Global Constant-Package

When you need literals and constants in forms, then the easiest way is to hardcode it in the sourcecode.

But please never do it the easiest way !

Have a look at this source-snippets and get a feeling, how to use them in your own code :

All my forms have attached libraries, in which I store my framework-functions.

One package spec. in this library is the package CONST. This package has no package body.


PACKAGE Const IS
/*
|| Name : Const
||
|| Function : This package contains all global Constants
||
|| Author : 08.08.1999, VOL
|| Updates :
*/

-- Alert
alr_Error CONSTANT VARCHAR2 (30) := 'AL_ERROR';
alr_Info CONSTANT VARCHAR2 (30) := 'AL_INFO';
alr_Warning CONSTANT VARCHAR2 (30) := 'AL_WARNING';

-- Mode
mod_Call_Form CONSTANT VARCHAR2 (10) := 'CALL_FORM';
mod_Open_Form CONSTANT VARCHAR2 (10) := 'OPEN_FORM';
mod_Go_Form CONSTANT VARCHAR2 (10) := 'GO_FORM';
mod_New_Form CONSTANT VARCHAR2 (10) := 'NEW_FORM';

-- Block, Record and Form-Status
sta_Changed CONSTANT VARCHAR2 (10) := 'CHANGED';
sta_Insert CONSTANT VARCHAR2 (10) := 'INSERT';
sta_New CONSTANT VARCHAR2 (10) := 'NEW';
sta_Query CONSTANT VARCHAR2 (10) := 'QUERY';

-- Other
CR CONSTANT VARCHAR2 (1) := CHR (10);
Tab CONSTANT VARCHAR2 (1) := CHR (9);
TRUE CONSTANT VARCHAR2 (10) := 'TRUE';
FALSE CONSTANT VARCHAR2 (10) := 'FALSE';

END Const;

This is only a very short part of my complete Const-package

All sourcecodes in which I now need a literal I change this to a constant from this package

e.g.

IF NAME_IN ('System.Last_Record') = Const.TRUE THEN
--do something;
ELSE
--do something different;
END IF;


This method of using a const-package can be enhanced, if you create another const-package in each form. Name it const_local.


PACKAGE Const_local IS
/*
|| Name : Const_local
||
|| Function : local Constant-Package
||
|| Author : 08.08.1999, VOL
|| Updates :
*/

-- Blocks
blk_Control CONSTANT VARCHAR2 (30) := upper ('Control');

-- Items
itm_Test CONSTANT VARCHAR2 (61) := upper ('Control.TI_TEST');

END Const_local;


With this local package you can now handle all the literals which are needed only in the form. This package can rapidly grow and is the central place for all other functions and procedures.

These packages offer some very important opportunities. All your literals are now constants. That means you have never runtime-errors, when you write a typo. You now have always compile-time-errors.

If you write a literal incorrect, than there is only one place in the const-package, where the constant is defined and the error can occur. Those error may occur, but they are found very fast and can be corrected directly.


Conclusion: Use the global Const-package in a library and use the local-package for all needs you have in the form itself.

Try and use it

September 24, 2005

OOW 2005-Summary

After a dozen of presentations, including my own, some of them were remarkable.

Steven with initially 10 minutes playing SET (www.setgame.com) and after that diving into FOR-Loops and BULK-Collects.














Tom with his 12 powerfulst ways using the Oracle DB 10g Rel. 2. (http://tkyte.blogspot.com/2005/09/oow-presentation-is-done.html)














and Scott in his keynote














The day after the convention I needed some rest. Where can this be done better, than near a little sea with some penguins, a waterfall and in the background some blue high mountains:

Oracle Open World 2005

This year it was my fourth Open World and the third time in the nicest little town of the United States: San Francisco

Larry announced the new life-time-support for all middleware-products. That was a hammer, because I know, what that means for a software-company like Oracle.

Congratulation for this brave statement !


The main topics of the OOW in my mind were:

  • Oracle Fusion
  • Golden future for BPEL


and here's one of Larrys toys down in the moscone center:

Initialize

... and another blog is online ...

This BLOG is for all Oracle Forms-Developer.

In the further posts I show examples of codes, discuss about new technologies in the forms-environment and help those of you, who need assistance in developing Forms.

Have a lot of fun with this new blog
Gerd