Stored Procedure Samples
------------------------
1 How to create stored procedures 
2 Stored Procedure Sample Files Purpose


1 How to create stored procedures 
---------------------------------
    Steps:
       1. Write procedure code in ESQL/C language.

       2. Edit dmconfig.ini to configure related directories

          DB_FODIR: The directory to store the source files as system
                    file objects
          DB_SPDIR: The directory to place dmconfig.ini and makefile. 
                    The shared object files for generated stored 
                    procedure are also placed this directory.
          DB_SPLOG: The directory to place log files.
          DB_SPINC: Specify extra compile option if necessary.
     
       3. Create stored procedure by issue create stored procedure 
          command in dmsqlc or by DBATool's create procedure function.


2 Stored Procedure Sample Files Purpose
---------------------------------------
    Sample: StoreProc\01simple.ec

    Purpose: 
        This sample program show how a stored procedure return the row count 
        of SYSTEM.SYSTABLE    

    Steps in Windows
        1. Start dmSQL from 'DBMaker 4.1' program folder (Win32).
           or type '/DBMAKER_HOME/bin/dmsqlc' command under UNIX.

        2. Execute the SQL command sequentially.
            dmSQL> connect to DBSAMPLE4 SYSADM;
            dmSQL> create procedure from 'C:\DBMaker\4.1\samples\StoreProc\01simple.ec';
            dmSQL> call simple(?);

    Steps in UNIX
        1. Type '/DBMAKER_HOME/bin/dmsqlc' command under UNIX.

        2. Execute the SQL command sequentially.
            dmSQL> connect to DBSAMPLE4 SYSADM;
            dmSQL> create procedure from '/DBMAKER_HOME/samples/StoreProc/01simple.ec';
            dmSQL> call simple(?);


    Sample: StoreProc\02sharedobj.ec

    Purpose:
        This sample program demostrates store procedure call shared 
        object(SYSTEM SP). It simulates a hospital registeration function, 
        insertdata, which accepts patient's number and name as input and 
        return the register number as result.   

    Steps in Windows
        1. Start dmSQL from 'DBMaker 4.1' program folder.

        2. Execute the SQL command sequentially.
            dmSQL> connect to DBSAMPLE4 SYSADM;
            dmSQL> call socreate(100,0,?);    
            dmSQL> create procedure from 'C:\DBMaker\4.1\samples\StoreProc\02sharedobj.ec';
            dmSQL> ?=call insertdata(100,'Joyce',?);

    Steps in UNIX
        1. Type '/DBMAKER_HOME/bin/dmsqlc' command under UNIX.

        2. Execute the SQL command sequentially.
            dmSQL> connect to DBSAMPLE4 SYSADM;
            dmSQL> call socreate(100,0,?);    
            dmSQL> create procedure from '/DBMAKER_HOME/samples/StoreProc/02sharedobj.ec';
            dmSQL> ?=call insertdata(100,'Joyce',?);


    Sample: StoreProc\03mail.ec

    Purpose:            
        This sample program show how to use stored procedure to send mail 
        using SMTP on Win32 or UNIX. This example can be used to send mails 
        from DBMaker database server. To execute this stored procedure, you 
        have to know the parameters to fill. There are four parameters for 
        this stored procedure. The first parameter is the e-mail address you 
        want to send mail to. The second parameter is the mail server's 
        name. The third parameter is the mail subject. The last parameter is 
        the mail content.

    Steps in Windows
        1. Start dmSQL from 'DBMaker 4.1' program folder (Win32).

        2. Execute the SQL command sequentially.
            dmSQL> connect to DBSAMPLE4 SYSADM;
            dmSQL> create procedure SYSADM.mail(char(32) name, char(32)smtp, char(32) subject, char(256) data);
            dmSQL> call mail('joyce@her.email.addr','your.email.relay.host',
                   'subject', 'content');

    Steps in UNIX
        1. Type '/DBMAKER_HOME/bin/dmsqlc' command under UNIX.

        2. Execute the SQL command sequentially.
            dmSQL> connect to DBSAMPLE4 SYSADM;
            dmSQL> create procedure SYSADM.mail(char(32) name, char(32)smtp, char(32) subject, char(256) data);
            dmSQL> call mail('joyce@her.email.addr','your.email.relay.host',
                   'subject', 'content');
