[comp.databases] I'm looking for embedded database/4gl/persistent PL code

lieuwen@mycella.cs.wisc.edu (Dan Lieuwen) (11/09/90)

I'm working on optimizing such code as part of my current research,
and would like to see if the ideas I've come up with work on any real
code (ie anything other than the code I cook up by hand in examples).
I prefer code (fragments) as written so I can get some intuition as to what is
going on, but could even use it with global renaming of fields, tables,
etc...  At least then, I'd have some idea as to what goes on in real
code sequences, even if I can't determine what the code sequences do.

Do you have any embedded SQL (or some other embedded query language)
with "master-detail" layout? Basically, I'm looking for code with the 
following form:

   loop while cursor1 not empty {
        ...
        loop while cursor2 not empty {
           ...
        }
        ...
   }

Do you have any persistent PL code in a language with sets and code like:
      
    for X in Set1 {
      ...
      for Y in Set2 {
        ...
      }
      ...
    }

Either sort would be great.

The 4gl code that would be desirable is of two forms.
I would love to get my hands on code that
has a call from within a cursor to a procedure that contains a query.
Also very desirable are procedures containing queries that call other
procedures containing queries.  

Thanks for your help.

Dan Lieuwen, Ph.D student University of Wisconsin-Madison
--
	
	--Dan

pcg@cs.aber.ac.uk (Piercarlo Grandi) (11/12/90)

On 9 Nov 90 14:31:24 GMT, lieuwen@mycella.cs.wisc.edu (Dan Lieuwen) said:

lieuwen> I'm working on optimizing such code as part of my current
lieuwen> research, [ ... ] Do you have any embedded SQL (or some other
lieuwen> embedded query language) with "master-detail" layout?
lieuwen> Basically, I'm looking for code with the following form:

lieuwen>    loop while cursor1 not empty {
lieuwen>         ...
lieuwen>         loop while cursor2 not empty {
lieuwen>            ...
lieuwen>         }
lieuwen>         ...
lieuwen>    }

I hope nobody would ever code such a loop (silly me :->), because it is
the N-squared (if the two underlying relations are not suitably sorted)
implementation of a join of some kind. Such things are best left to the
DBMS implementor. It looks pretty much a waste to have a wonderful query
planner in the DBMS engine and then bypass it...

Note that you might instead be trying to do a closure of some
relationship, but that is not done like above.
--
Piercarlo Grandi                   | ARPA: pcg%uk.ac.aber.cs@nsfnet-relay.ac.uk
Dept of CS, UCW Aberystwyth        | UUCP: ...!mcsun!ukc!aber-cs!pcg
Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk

lieuwen@mycella.cs.wisc.edu (Dan Lieuwen) (11/16/90)

lieuwen> I'm working on optimizing such code as part of my current
lieuwen> research, [ ... ] Do you have any embedded SQL (or some other
lieuwen> embedded query language) with "master-detail" layout?
lieuwen> Basically, I'm looking for code with the following form:

lieuwen>    loop while cursor1 not empty {
lieuwen>         ...
lieuwen>         loop while cursor2 not empty {
lieuwen>            ...
lieuwen>         }
lieuwen>         ...
lieuwen>    }

>>I hope nobody would ever code such a loop (silly me :->), because it is
>>the N-squared (if the two underlying relations are not suitably sorted)
>>implementation of a join of some kind. Such things are best left to the
>>DBMS implementor. It looks pretty much a waste to have a wonderful query
>>planner in the DBMS engine and then bypass it...

==> People write this code for several reasons.

1) They were brought up doing database programming in another environment,
   and never learned how to deal with another environment.

2) Some of the ... code has integrity constraint checking.  I never would
   have believed it before starting to look over embedded COBOL, but was
   told by a data processing person that the supplied integrity checking
   is 
   a) Too expensive and
   b) Too restrictive (they want exceptions)

3) People want a selection criterion on cursor1 that the database won't 
   supply.

4) The inner cursor is hidden in a function/procedure call.

I promise not to tell anyone about your coding style if you provide any
code.  I'll only mention that I've seen such code.

Dan

--
	
	--Dan