Progress
Embedded SQL-92
Guide and Reference


Coding Guidelines

Some general coding guidelines for an application developer using ESQL follow:

EXAMPLE

The following example reverses the case of the reserved word NULL:

EXEC SQL
     SELECT ename
     FROM employee
     WHERE commission is null ; 

This does not affect ESQLC since reserved words in ESQL statements are not case sensitive.

EXAMPLE

For example, to access the customer table, specify the owner name john with the customer table:

EXEC SQL
     SELECT cust_no, last_name
     FROM john.customer ; 

EXAMPLES

For example, the following declaration in the declare section is invalid, and the precompiler returns an error:

#define MAXNAMELEN 18
/*
** THIS DECLARATION IS INVALID
*/
EXEC SQL BEGIN DECLARE SECTION ;
     char last_name [MAXNAMELEN + 1] ;
EXEC SQL END DECLARE SECTION ; 

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:

#define MAXNAMELEN_P1 19
 
EXEC SQL BEGIN DECLARE SECTION ;
  char last_name [MAXNAMELEN_P1] ;
EXEC SQL END DECLARE SECTION ; 

EXAMPLE

The following example shows how to use the #define symbol:

MAX_SALARY:
     #define MAX_SALARY 10000
EXEC SQL
     SELECT ename, salary
     FROM employee
     WHERE salary = MAX_SALARY ; 

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