Creating Procedures
A procedure is a series of statements written in 4GL, Ingres SQL (called a database procedure), or 3GL. You define the procedure using ABF. You can include procedures anywhere in your application that uses a frame (including the start frame). When you call the procedure, ABF executes the commands it contains.
You can use the following types of procedures in ABF applications:
4GL procedures
A 4GL procedure can call any other type of procedure. The procedures must be declared to ABF. A 4GL procedure does not include forms and therefore cannot include statements that refer to fields on a form.
3GL procedures
A host language procedure can access forms or the database through embedded query language statements. A 3GL procedure can call other 3GL procedures or database procedures. As long as these internal procedures are not called directly from 4GL, it is not necessary to define them to ABF.
Place the code for these nested procedures in a file that ABF knows about or include the object module in the default link options list. It is always safer to define procedures to ABF, whether or not they are called directly from 4GL.
Database procedures
A database procedure is a series of Ingres SQL statements and is stored as an object in the database. A database procedure is a library-only procedure; it cannot call any of the other procedure types. Also, a database procedure cannot include any statements that refer to forms.
You cannot use database procedures in your applications if you want them to access non-Ingres databases through an Enterprise Access Product.
Examples--4GL procedures:
The first procedure, addtax, performs a frequently used tax calculation, then returns a result to the calling frame.
procedure addtax (cost = float8,
taxrate = float4) =
begin
cost = cost + (cost * taxrate);
return cost;
end
The second procedure, find, returns a customer name from the database, given a customer number.
procedure find (cust_num = integer) =
declare cust_name = char(31)
begin
cust_name := '';
find := select cust_name = name
from customer
where number = :cust_num;
return cust_name;
end