* ocs_ex.pco
* Description :
* This program declares a cursor which retrieves rows from
* the 'titles' table based on condition checking for NULLS
* in the NON-ANSI style ( CS_OPT_ANSINULL = CS_FALSE ).
* The program will be compiled using the -x option which will
* use an external configuration file (ocs.cfg) based on the
* name of the application. The name of the application is
* defined at the time of INITIALIZING the application.
*
*
* Notes : Copy the file ocs.cfg in this directory to the $SYBASE direc-
* tory or add the entries from the section TEST1 in this file
* to your existing ocs.cfg file in the $SYBASE directory.
* Compile the program using the pre-processor flag -x.
* See the attached ocs.cfg file for details on the properties
* being set.
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 INITIALIZE_APPLICATION APPLICATION_NAME
= "TEST1" 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.
Set the precompiler option in the makefile: cobpre
-x.
The following is a sample configuration file for the preceding program:
[DEFAULT]
;
[TEST1]
;This is name of the application set by INITIALIZE_APPLICATION. ;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.