Was this helpful?
Coding Requirements for Writing EQUEL Programs
The following sections describe coding requirements for writing EQUEL programs.
Comments Embedded in C Output
Each EQUEL statement generates one comment and a few lines of C code. You may find that the preprocessor translates 50 lines of EQUEL into 200 lines of C. This may result in confusion about line numbers when you are debugging the original source code. To facilitate debugging, each group of C statements associated with a particular statement is preceded by a comment corresponding to the original EQUEL source. (Note that only executable EQUEL statements are preceded by a comment.) Each comment is one line long and informs the reader of the file name, line number, and type of statement in the original source file. The -# flag to equel makes the C comment a C compiler directive, causing any error messages generated by the C compiler to refer to the original file and line number; this may be useful in some cases.
One consequence of the generated comment is that you cannot comment out embedded statements by putting the opening comment delimiter on an earlier line. You have to put the opening comment delimiter on the same line, before the ## delimiter, to cause the preprocessor to treat the complete statement as a C comment.
Embedding Statements Inside C If Blocks
As mentioned above, the preprocessor may produce several C statements for a single EQUEL statement. However, all the statements generated by the preprocessor are delimited by left and right braces, composing a C block. Thus the statement:
if   (!dba)
##   retrieve (passwd = s.#passwd)
##   where s.username = userid
produces legal C code, even though the QUEL retrieve statement produces more than one C statement. However, two or more EQUEL statements generate multiple C blocks, so you must delimit them yourself, just as you would delimit two C statements in a single if block. For example:
if   (!dba)
     {
##   message "Confirming your user id"
##   retrieve (passwd = security.#passwd)
##   where security.usrname = userid
     }
An EQUEL Statement that Does Not Generate Code
The declare cursor statement does not generate any C code. This statement should not be coded as the only statement in C constructs that does not allow null statements. For example, coding a declare cursor statement as the only statement in a C if statement not bounded by left and right braces would cause compiler errors:
if    (using_database)
##    declare cursor empcsr for retrieve (employee.ename)
    else
      printf("You have not accessed the database.\n");
The code the preprocessor generates is:
if (using_database)
else
   printf("You have not accessed the database.\n");
which is an illegal use of the C else clause.
Last modified date: 11/09/2022