Scoping rules

The precompiler supports the C programming rules for variable scoping. Host variables defined within nested programs can use the external clause plus the variable name. For example:

FILE 1:
CS_CHAR  username[31]
 main()
 {
     sub1();
     printf(“%s\n”, username);
 }
FILE 2:
void sub1()
 {
     exec sql begin declare section;
     extern char username[31];
     exec sql end declare section;
    exec sql select USER() into :username;
     return;
 }