Skip to main content

Posts

Showing posts from November, 2008

4GL's virtues (Part 1) Extensibility with C

One of 4GL's virtues is it's extensibility with C. You can call custom C programs from within 4GL code and pass values between them byval or byref.
Is there something that cannot be done by using 4GL? you need to interact with the OS? do you want do to something more advanced? Call C to the rescue.

A trivial example is generating random numbers, ie random - generic serial numbers. There is a session directive supported by Ingres that sets the seed so it makes it easy to fill a tablefield with random numbers (a part of a larger code sample follows) :


set random_seed


while rowno <= quantity do

loadtable cylki (sn = 'GE'+ varchar(random()));

rowno = rowno + 1;

endwhile;

Which loads a tablefield with as many SN's as the quantity variable directs.

But the set random_seed directive and the random function are supported on Ingres 2.6 onwards.What to do with older Ingres version? Replace functionality by calling a C program.

So the 4GL code now becomes :
while …