[comp.databases] Ingres FRS, initialize and finalize

wengland@stephsf.stephsf.com (Bill England) (07/12/90)

Has anyone noticed that the FRS INITIALIZE and FRS FINALIZE statements
are not semetric?  During an initialize a begin/end section can be 
declared that allows loading data into tables but, you can't have
a similar structure after a finalize to unload the tables.

Is this fixed/changed in more recent ingres versions?

 +--------
 |  Bill England
 |  Stephen Software Systems, Inc.,   Tacoma Wa.
 |  wengland@stephsf.com              +1 206 564 2122
 |
  * *      H -> He +24Mev
 * * * ... Oooo, we're having so much fun making itty bitty suns *
  * *

jkrueger@dgis.dtic.dla.mil (Jon) (07/13/90)

wengland@stephsf.stephsf.com (Bill England) writes:

>Has anyone noticed that the FRS INITIALIZE and FRS FINALIZE statements
>are not symmetric?  During an initialize a begin/end section can be 
>declared that allows loading data into tables but, you can't have
>a similar structure after a finalize to unload the tables.

Not quite.  INITIALIZE and FINALIZE have always allowed putting
and getting values to a form:

/* syntax for embedded QUEL; for SQL replace ## with EXEC FRS */
##	initialize (accno = 5)
##	finalize (c_accno = accno)

The begin/end section is for specifying arbitrary other actions to
take place at the beginning and end of the display loop.  You can
place PUTFORM and GETFORM there if you like, which produces exactly
the same effect.  Thus INITIALIZE and FINALIZE are just handy
markers of the boundaries of the display loop if you like, and also
allow a well defined place to put and get forms data on entry and exit.

Note that BREAKDISPLAY doesn't perform the FINALIZE actions or any
validation checks.  ENDDISPLAY does both.  INITIALIZE and FINALIZE
don't require a form name because they're only defined following a
DISPLAY loop.  PUTFORM and GETFORM default to the currently displayed
form but can take a different form name -- change things behind the
user's back!  INITIALIZE and FINALIZE are performed only outside the
display loop,  PUTFORM and GETFORM at any time (thus usually used
inside).  INITIALIZE gives control to the forms runtime system,
FINALIZE gives control back to the application.

Another way of thinking about the forms runtime system is an event
driven interface.  It can process some events itself, like movement
with a field, entering values in a field, advancing from field to
field, scrolling the form or tablefield.  It passes other events on to
the application.  DISPLAY, INITIALIZE, and FINALIZE run an event loop.
ACTIVATE passes events to the application.  ENDDISPLAY and BREAKDISPLAY
break out of the loop.  PUTFORM and GETFORM allow the application to
manipulate the form without leaving the loop.  So, both GETFORM and
FINALIZE get values from the form.  But GETFORM allows the forms
runtime system to continue looping for events.  FINALIZE is performed
after the loop is terminated by ENDDISPLAY.

EQUEL/C sample code follows.  Tested on INGRES OSx Version 6.1/01u
(pyr.u42/04), but provided without endorsement, strictly "as is".
If doing all this and accessing a database too seems complicated,
that's why there's ABF/OSL.

-- Jon

Makefile
--------
INGLIB = $$II_SYSTEM/ingres/lib/libingres.a
.SUFFIXES:	.qc .exe
.qc.exe:	;
	eqc -d $*
	cc -c $*.c
	rm $*.c
	cc -o $*.exe $*.o $(INGLIB) -lm -lc

testme.qc
---------
/* testme.qc -- uses form "fooform" with an integer field "accno" */
main()
{
	int	got;
	startup();
	got = run();
	cleanup();
	printf("final value %d\n", got);
}

##int
##run()
##{
##	int	c_accno = 3;
##	display fooform
##	initialize (accno = 5)
##	{
##		message "initializing..."
##		sleep 1
##	}
##	activate menuitem "Increment":
##	{
##		getform (c_accno = accno)
		++c_accno;
##		putform (accno = c_accno)
##	}
##	activate menuitem "Quit":
##	{
##		enddisplay
##	}
##	finalize (c_accno = accno)
##	{
##		message "finalizing..."
##		sleep 1
##	}
	return c_accno;
##}

##startup()
##{
##	ingres mydatabase
##	forms
##	forminit fooform
##}

##cleanup()
##{
##	endforms
##	exit
##}
-- 
Jonathan Krueger    jkrueger@dtic.dla.mil   uunet!dgis!jkrueger
Drop in next time you're in the tri-planet area!