Progress
Embedded SQL-92
Guide and Reference
Coding Guidelines
Some general coding guidelines for an application developer using ESQL follow:
EXAMPLE
- The character strings used in an ESQL program must be null terminated.
- The SQL-92 operator that shows equality is a single equals sign ( = ). The C Language operator that evaluates for equality is a double equals sign ( == ), and in C the single equals sign ( = ) is the assignment operator. Often all of these operators will be in an embedded SQL C Language source program.
- Use the WHENEVER statement in an ESQL program to check for error conditions. This statement provides more flexibility and reduces the code size of the application.
- Problems occur if any of the SQL reserved words are in #define statements of included header files and you specify the +P option when executing ESQLC. When you specify the +P option, the source files are passed through the C preprocessor before the ESQLC statements are translated. One frequent problem is the reserved word NULL that the standard header file
stdio.h
#defines. In such cases, use one of the following solutions:The following example reverses the case of the reserved word NULL:
This does not affect ESQLC since reserved words in ESQL statements are not case sensitive.
EXAMPLEFor example, to access the customer table, specify the owner name john with the customer table:
EXAMPLES
For example, the following declaration in the declare section is invalid, and the precompiler returns an error:
MAXNAMELEN is defined with a #define symbol. To handle such requirements, define a new symbol for the required value and use the new symbol, as shown in this example:
EXAMPLEThe following example shows how to use the #define symbol:
Specify all the columns in the SELECT list of a SELECT statement instead of specifying a ( * ). This might improve the readability of the SELECT statement. In addition, if more columns are added to the database table definition later, you do not have to change your statement unless you choose to select the additional columns.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |