[comp.databases] Informix Lookup Joins

marta@CS.UCLA.EDU (05/06/88)

Help!!!!!!!!!


I'm want to do something similar to using "Lookup Joins" but that
allows modification of the data.

I have two tables: *schedule* and *courses*.
Table *schedule* is a list of courses taught during the quarter;
the primary keys are attributes s_number and s_section 
[number and section of course]. The table *courses* is a list 
of courses offered by the department; the primary key is attribute 
c_number [the number of the course]. 

*schedule*				*courses*

s_number 				c_number
s_section				c_title
s_title					c_units
s_instructor				c_type (Lab, Lect, etc)
s_time					c_inst_charge
s_room

When I make an entry into the *schedule* table using a screen form,
I want the s_title attribute to be set equal to the c_title attribute
for the corresponding course number, i.e.:

 		if s_number = c_number then
			s_title := c_title

The effect should be that of providing default values for a field
(course title) depending on another field (course number).
As soon as the course number is entered in the table *schedule*
the course title is provided from the table *courses*
But, if the course title is not correct, I want to be able to modify it.
and store it in the table *schedule* (I do NOT want to modify
c_title).

The reason for this, (yes, there is a 'logical' explanation!) is that
we have graduate courses with a generic number (eg 299) which has
an official title of "Current Topics in Computer Science". The
real title changes everytime it is taught to, for example,
"Special Topics in High Speed Computing". If I required that the
title be entered every time a course is taught for every course, 
it would be a big hassle (lookup time, data entry time, error prone, etc.)
Any ideas? is this at all possible using Informix?

Thank you for your time.

 =============================================================
| Marta E. Cervantes  (213) 206-3321                          |
| 3731L Boelter Hall, UCLA, Los Angeles, CA 90024-1596        |
| UUCP:...!{ihnp4,ucbvax,sdcrdcf,{hao!cepu}}!ucla-cs!marta    |
| ARPA: marta@cs.ucla.edu                                     |
 =============================================================

allbery@ncoast.UUCP (Brandon S. Allbery) (05/16/88)

As quoted from <11983@shemp.CS.UCLA.EDU> by marta@CS.UCLA.EDU:
+---------------
| I'm want to do something similar to using "Lookup Joins" but that
| allows modification of the data.
| 
| When I make an entry into the *schedule* table using a screen form,
| I want the s_title attribute to be set equal to the c_title attribute
| for the corresponding course number, i.e.:
| 
|  		if s_number = c_number then
| 			s_title := c_title
| 
| The effect should be that of providing default values for a field
| (course title) depending on another field (course number).
| As soon as the course number is entered in the table *schedule*
| the course title is provided from the table *courses*
| But, if the course title is not correct, I want to be able to modify it.
| and store it in the table *schedule* (I do NOT want to modify
| c_title).
+---------------

We do this by creating a special screen of display-only fields after all the
data entry screens; doing the "lookup joining" into the display-only fields
on that screen; then using something like:

	before editadd editupdate of s_number
		let x001 = f022

	after editadd editupdate of s_number
		if x001 != f022 then
			let f023 = x002

where "f023" is the s_title field and the lookup is coded like:

	f022 = s_number, lookup x002 = c_title joining *c_number;

(This is Informix 3.3 syntax, it may vary slightly for Informix-SQL.)  That
lets us assign the initial s_title and then change it if we want.

The save and test against the original value of f022 is needed so that the
s_title isn't forced back to the c_title value when you press RETURN on the
field without entering anything.
-- 
	      Brandon S. Allbery, moderator of comp.sources.misc
	{well!hoptoad,uunet!marque,cbosgd,sun!mandrill}!ncoast!allbery
Delphi: ALLBERY						     MCI Mail: BALLBERY