From: fgreene@hayes.com
Newsgroups: comp.databases.oracle
Subject: Re: SQL*Forms Trigger Optimization
Date: 28 Dec 92 08:38:35 EDT
Organization: Hayes Microcomputer Products, Norcross, GA

In article <1992Dec23.220119.11645@cbfsb.cb.att.com>, jurista@cbnewsg.cb.att.com (james.jurista) writes:
> Greetings, netters:
> 
> I'm using SQL*Forms 3.0 under Oracle v6, and my question is this:
> 
> Is is more efficient to code one form-level trigger or many block-level
> triggers to accomplish a task.  For example, I have triggers with the
> following structure:
> 
> 	(Form level KEY-DOWN)
> 	declare
> 		valid boolean := TRUE;
> 	begin
> 		if :system.cursor_block = 'block1' then
> 			procedure1(valid);
> 		elsif :system.cursor_block = 'block2' then
> 			procedure2(valid);
> 		elsif :system.cursor_block = 'block3' then
> 			procedure3(valid);
> 		else
> 			valid := FALSE;
> 		end if;
> 		if (valid = TRUE) then
> 			down;
> 		end if;
> 	end;
> 
> 	(Block level KEY-DOWN (one for each of blocks 1, 2, and 3))
> 	declare
> 		valid boolean := TRUE;
> 	begin
> 		procedureX(valid);
> 		if (valid = TRUE) then
> 			down;
> 		end if;
> 	end;
> 
> 
> I believe that it's good practice to define each trigger as close as
> possible to its point of use (in this case, at the block level), but
> this can greatly increase the size of the INP file and thus, I assume,
> the memory requirements since a larger program must be loaded at run
> time.  From that perspective it would seem that the form-level approach
> is more prudent.  
> 
> It comes down to this:  which is more efficient?  And, while we're at
> it, which style do you prefer.
> 
> Please e-mail responses, I will post a summary.  Thanks in advance for
> any assistance!
> 
> Jim
> 
> -=-=-=-=-=- Jim Jurista =-=-=-= Internet: jurista@llssak.attmail.com =-=-=-=-
>                   "Musical elation is my only consolation..."
>            Views/opinions above:  Mine, not AT&T's nor probably yours
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

In your definition of 'efficiency' you need to consider both machine efficiency
and development efficiency.  If you replicate the required function within
multiple trigger steps, how do you correct any errors in logic (yes, I make
logic errors) or accommodate changes in design logic?  If the trigger logic
is replicated, you (or whoever follows you) has to remember or trace down 
each of the multiple triggers affected.  Far better to consolidate these
steps into a single trigger (procedure, actually) at the form level with good
documentation as to its purpose.

I never thought of it in these terms before, but what you really need to do is
normalize your triggers just as you normalize your table design.


  ---------------------------------------------------------------------------
  |      Frank Greene                  |          //////  //////             |
  |      DELPHI SYSTEMS, Inc.          |           ////    ////              |
  |      Telephone [615] 458-6032      |          ////    ////  //////       |
  |      324 Ootsima Way               |         ////    ////    ////        |
  |      Loudon, TN 37774              |        //////  //////  //////       |
  ----------------------------------------------------------------------------
  |         Of course, any opinions or suggestions are strictly my own       |
  ----------------------------------------------------------------------------