Was this helpful?
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
How You Can Use a Procedure in an Application
1. Create the procedure using the ABF Edit an Application frame and the Create a Procedure frame for the procedure type you choose.
2. Write the code for the procedure as follows:
For 4GL and 3GL procedures, use the Edit operation of the Edit a Procedure Definition frame to call your default editor.
For database procedures, use the SQL create procedure statement.
You must code database procedures outside of ABF. See the SQL Reference Guide for more information about creating database procedures.
Creating a procedure is similar to creating a frame. Select Procedure from the Create a Frame or Procedure pop-up frame of the Edit an Application frame. You see a menu of the types of procedures, as in the following figure:
The following menu operations are available for this frame:
Select
Displays the Create a Proceduretype Procedure frame for the selected type of procedure
Other Languages
Displays a list of all callable non-embedded languages supported by your site
Cancel, Help
Perform standard operations
The procedure type you specify determines the source file extension, which in turn determines the compiler to be used. The programming language also correlates with the procedure type. ABF requires one of these extensions:
Operating System
SQL File Extension
non-SQL File Extension
Programming Language
Windows
.osq
none
4GL/SQL
 
.sc
.c
Embedded SQL/C
 
.scb
.cob
Embedded SQL/COBOL
UNIX
.osq
none
4GL/SQL
 
.sc
.c
Embedded SQL/C
 
.scb
.cob
Embedded SQL/COBOL
 
.sf
.f
Embedded SQL/FORTRAN
VMS
.osq
none
4GL/SQL
 
.sa
.ada
Embedded SQL/ADA
 
.sc
.c
Embedded SQL/C
 
.scb
.cob
Embedded SQL/COBOL
 
.sf
.for
Embedded SQL/FORTRAN
Last modified date: 08/28/2024