ESQL/C Samples
--------------
1 Sample Files Purpose
2 How to Run ESQL/C Samples in Windows
3 How to compile an ESQL/C program in UNIX
4 How to run the ESQL/C sample programs in UNIX


1 Sample Files Purpose
------------------------

    Sample: 01base.ec

    Purpose:
        This sample demostrates how to use ESQL/C to develop database 
        application perform following functions.
        1. use sqlca, dbenvca as global variable
        2. connect to database
        3. insert (id,name,address) to employee table
        4. select
        5. delete
        6. update
        7. fetch all data from employee table
        8. disconnect db


    Sample: 02cursor.ec 

    Purpose:
        This sample demostrates how to use ESQL/C to develop database 
        application perform following functions.
        1. declare, open, close
        2. select cursor with fetch next only
        3. select scroll cursor with fetch next, previous, last, first, 
           relative n, absolute n
        4. updateble cursor for update, and delete


    Sample: 03blob.ec

    Purpose:
        This sample demostrates get/put BLOB data by ESQL/C. 
        1. put BLOB "putblob.bmp" into Card table as the fifth row.
        2. get BLOBs from Card table, save as files "BMP*.BMP".


    Sample: 04dynamic.ec

    Purpose:
        This sample demostrates 4 types of dynamic ESQL, including
        1. type 1 : insert, update, delete
        2. type 2 : insert, update, delete
        3. type 3 : select
        4. type 4 : select 


2 How to Run ESQL/C Samples in Windows
--------------------------------------
    We use 01base.ec as example here to demostrate three main step to run 
    the sample.

    Preprocess:
        1. Start the 'DBSAMPLE5' database in client-server mode.
        2. Start the 'ESQL for C Language' utility from Program folder.
        3. Click File/Open menu item, a Open dialog box appears.
        4. Select and open this sample.
        5. In 'ESQL for c Language' utility, select database 'DBSAMPLE5'.
        6. Select Esql/Go menu item to do processing, which generate a 
           .c file with the same name.

    Build: 
        1. Use C Compiler of Microsoft (i.e. Visual C ++ 6.0 or compatible 
           compiler).
        2. Add 'C:\DBMaker\5.4\include' to the 'Include Files' Search Path.
        3. Add 'C:\DBMaker\5.4\lib' to the 'Library Modules' Search Path.
        4. Add 'C:\DBMaker\5.4\lib\dmapi54.lib' to the Link Library Modules.
        5. Build the 01base.exe file.

    Execute:
        1. Choose and run the 'Execute 01base.exe' command.
        
        
3 How to compile an ESQL/C program in UNIX
------------------------------------------
        1. Start the database which your ESQL/C program will access, 
           because the DBMaker ESQL/C preprocessor dmppcc will connect
           to that database.

        2. Preprocess your ESQL/C program as below.

           % dmppcc -d DBSAMPLE5 -u SYSADM
   
           where DBSAMPLE5 is the started database name, and the SYSADM
           is the user identifier  connected to database. You
           can just type dmppcc -h for usage.

        3. Check what compiler is provided on your machine, for example
           'cc'.

        4. Set the include path to the 'inlcude' directory under the 
           home directory of the user 'dbmaker' and compile the C 
           program. For example:

              % cc -c -I/APP_HOME/include 01base.c

        5. Set the library path to the 'lib' directory under the home 
           directory of the user 'dbmaker'(/APP_HOME/lib). 

        6. Link libdmapic.a, to make an application that will run in the
           Client-Server environment. For example :

          % cc -o 01base 01base.o -L/APP_HOME/lib -ldmapic -lm -ldl


4 How to run the ESQL/C sample programs in UNIX
-----------------------------------------------
    Steps:
        1. Start the 'DBSAMPLE5' database in client-server mode.  

        2. Type 'make' command under the shell environment.

           % make

        3. Type '01base' command under the shell environment.

           % ./01base

           You will see following results:

           John's address is Xi'an Torch Road No.1
           Name = Mary Black, Address = Beijing
           Name = Jane White, Address = guangzhou

