Same Embedded SQL program with the -e option

* Program name: ocs_test.cp 
 *
 * Description  : This program declares a cursor that retrieves rows
 * from the 'titles' table based on condition checking for NULLS
 * in the NON-ANSI style.
 * The program will be compiled using the -e option, which will
 * use the server name that the application connects to, as the
 * corresponding section to look up in the configuration file.
 *
 
      EXEC SQL INCLUDE SQLCA END-EXEC.
        
      EXEC SQL BEGIN DECLARE SECTION END-EXEC.
                   ...
    01    TITLE-ID          PIC X(6).
    01    PRICE             PIC X(30).
      EXEC SQL END DECLARE SECTION END-EXEC.
                   ...  
 
      EXEC SQL CONNECT :UID IDENTIFIED BY :PASS END-EXEC.
      EXEC SQL USE pubs2 END-EXEC.
 
 * Declare and open the cursor for select 
      EXEC SQL DECLARE title_list CURSOR FOR 
                   SELECT title_id, price FROM titles 
                    WHERE price != NULL END-EXEC.
 
      EXEC SQL OPEN title_list END-EXEC.
 
 * Fetch the data into host variables.
      PERFORM FETCH-LOOP UNTIL  SQLCODE = 100.
 
                   ...
 
      EXEC SQL CLOSE title_list END-EXEC.
      EXEC SQL DEALLOCATE CURSOR title_list END-EXEC.
 
      STOP RUN.
 
  FETCH-LOOP.

     EXEC SQL FETCH title list INTO
                   :TITLE-ID,
                   :PRICE END-EXEC.
           ...

     END-IF.

NotePrecompiler option to set in the makefile: cobpre -e.

The following is a sample configuration file for the preceding program:

[DEFAULT]
 ;
 
 [SYBASE]
 ;This is name of the server that the application connect to. Therefore
 ;this is the section that will be referred to a runtime.
 ;
 CS_OPT_ANSINULL=CS_FALSE
 ;The above option will enable comparisons of nulls in the NON-ANSI
 ;style.

The above configuration files have been vastly simplified. A typical Open Client/Server configuration file would be in the following format:

[DEFAULT]
 ;
 [ANSI_ESQL]
 CS_CAP_RESPONSE=CS_RES_NOSTRIPBLANKS
 CS_EXTRA_INF=CS_TRUE
 CS_ANSI_BINDS=CS_TRUE
 CS_OPT_ANSINULL=CS_TRUE
 CS_OPT_ANSIPERM=CS_TRUE
 CS_OPT_STR_RTRUNC=CS_TRUE
 CS_OPT_ARITHABORT=CS_FALSE
 CS_OPT_TRUNCIGNORE=CS_TRUE
 CS_OPT_ISOLATION=CS_OPT_LEVEL3
 CS_OPT_CHAINXACTS=CS_TRUE
 CS_OPT_CURCLOSEONXACT=CS_TRUE
 CS_OPT_QUOTED_IDENT=CS_TRUE
 ;
 ;The following is a sample section showing how to alter standard
 ;configuration:
 ;
 [RELEVANT_SECION_NAME]
 ;
 ;Use most of the ANSI properties defined above,
 ;
 include=ANSI_ESQL
 
 ;but override some default properties
 
 CS_OPT_ANSINULL=CS_TRUE    ; enable non-ansi style null comparisons
 CS_OPT_CHAINXACTS=CS_FALSE ; run in autocommit mode